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 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
- Number of terms in Geometric Series with given conditions
- Pairs from an array that satisfy the given condition
- Count valid pairs in the array satisfying given conditions
- Number of sextuplets (or six values) that satisfy an equation
- Count triplet pairs (A, B, C) of points in 2-D space that satisfy the given condition
- Count Distinct Non-Negative Integer Pairs (x, y) that Satisfy the Inequality x*x + y*y < n
- Find two numbers whose sum and GCD are given
- Given two numbers a and b find all x such that a % x = b
- Find LCM of rational numbers
- Find the sum of the all amicable numbers up to N
- Find k numbers which are powers of 2 and have sum N | Set 1
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.