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)
- Find smallest values of x and y such that ax - by = 0
- Find the values of X and Y in the Given Equations
- Find minimum possible values of A, B and C when two of the (A + B), (A + C) and (B + C) are given
- Count numbers < = N whose difference with the count of primes upto them is > = K
- Print values of 'a' in equation (a+b) <= n and a+b is divisible by x
- Sum of even values and update queries on an array
- Possible to form a triangle from array values
- Maximum and Minimum Values of an Algebraic Expression
- Find the minimum value of m that satisfies ax + by = m and all values after m also satisfy
- Number of sextuplets (or six values) that satisfy an equation
- Frequency of each element of an array of small ranged values
- Construct a frequency array of digits of the values obtained from x^1, x^2, ........, x^n
- Maximize a number considering permutations with values smaller than limit
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.