Given an integer n, the task is to find two integers a and b which satisfy the below conditions:
- a % b = 0
- a * b > n
- a / b < n
If no pair satisfies the above conditions then print -1.
Note: There can be multiple (a, b) pairs satisfying the above conditions for n.
Input: n = 10 Output: a = 90, b = 10 90 % 10 = 0 90 * 10 = 900 > 10 90 / 10 = 9 < 10 All three conditions are satisfied. Input: n = 1 Output: -1
Approach: Let’s suppose b = n, by taking this assumption a can be found based on the given conditions:
- (a % b = 0) => a should be multiple of b.
- (a / b < n) => a / b = n – 1 which is < n.
- (a * b > n) => a = n.
Below is the implementation of the above approach:
a = 90, b = 10
- Count of N digit numbers possible which satisfy the given conditions
- Count all possible N digit numbers that satisfy the given condition
- Find x, y, z that satisfy 2/n = 1/x + 1/y + 1/z
- Find the minimum value of m that satisfies ax + by = m and all values after m also satisfy
- Find n positive integers that satisfy the given equations
- Pairs from an array that satisfy the given condition
- Generate elements of the array following given conditions
- Count of sub-sequences which satisfy the given condition
- Generate an array of size K which satisfies the given conditions
- Number of terms in Geometric Series with given conditions
- Count index pairs which satisfy the given condition
- Number of sextuplets (or six values) that satisfy an equation
- Count valid pairs in the array satisfying given conditions
- Count Distinct Non-Negative Integer Pairs (x, y) that Satisfy the Inequality x*x + y*y < n
- Count triplet pairs (A, B, C) of points in 2-D space that satisfy the given condition
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.