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
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- 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 n positive integers that satisfy the given equations
- Find the minimum value of m that satisfies ax + by = m and all values after m also satisfy
- Find the Number of Permutations that satisfy the given condition in an array
- Find an integer in the given range that satisfies the given conditions
- Count of sub-sequences which satisfy the given condition
- Satisfy the parabola when point (A, B) and the equation is given
- Pairs from an array that satisfy the given condition
- Pair of integers (a, b) which satisfy the given equations
- Count of indices in an array that satisfy the given condition
- Count index pairs which satisfy the given condition
- Count of Fibonacci pairs which satisfy the given equation
- Number of sextuplets (or six values) that satisfy an equation
- Append two elements to make the array satisfy the given condition
- Count of unordered pairs (x, y) of Array which satisfy given equation
- 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
- Generate N integers satisfying the given conditions
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.