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
- Find the values of X and Y in the Given Equations
- Comparing X^Y and Y^X for very large values of X and Y
- Find smallest values of x and y such that ax - by = 0
- Sum of even values and update queries on an array
- Sum of all natural numbers from L to R ( for large values of L and R )
- Possible to form a triangle from array values
- Print values of 'a' in equation (a+b) <= n and a+b is divisible by x
- 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
- Construct a frequency array of digits of the values obtained from x^1, x^2, ........, x^n
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.