Given two integers A and B. The task is to find the count of all possible values X such that A % X = B. If there are infinite number of possible values then print -1.
Input: A = 21, B = 5
8 and 16 are the only valid values for X.
Input: A = 5, B = 5
X can have any value > 5
Approach: There are three possible cases:
- If A < B then no value of X can satisfy the given condition.
- If A = B then infinite solutions are possible. So, print -1 as X can be any value greater than A.
- If A > B then the number of divisors of (A – B) which are greater than B is the required count.
Below is the implementation of the above approach:
- Count of alphabets whose ASCII values can be formed with the digits of N
- Number of values of b such that a = b + (a^b)
- Count numbers < = N whose difference with the count of primes upto them is > = K
- Find minimum possible values of A, B and C when two of the (A + B), (A + C) and (B + C) are given
- Comparing X^Y and Y^X for very large values of X and Y
- Find the values of X and Y in the Given Equations
- Find smallest values of x and y such that ax - by = 0
- Eigenspace and Eigenspectrum Values in a Matrix
- Sum of all natural numbers from L to R ( for large values of L and R )
- Sum of values of all possible non-empty subsets of the given array
- Sum of even values and update queries on an array
- Print values of 'a' in equation (a+b) <= n and a+b is divisible by x
- Possible to form a triangle from array values
- Maximum and Minimum Values of an Algebraic Expression
- Product of values of all possible non-empty subsets of given Array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.