We Are Discuss About CODECHEF SOLUTION
Lcm hates Gcd Codechef Solution
Lcm hates Gcd Codechef Solution
Problem
Chef has two integers � and �.
Chef wants to find the minimum value of lcm(�,�)−gcd(�,�) where � is any positive integer.
Help him determine this value.
Note: gcd(�,�) denotes the greatest common divisor of � and � and lcm(�,�) denotes the least common multiple of � and �.
Input Format
- The first line contains a single integer � — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two space-separated integers � and � — the integers mentioned in the statement.
Output Format
For each test case, output the minimum value of lcm(�,�)−gcd(�,�).
Constraints
- 1≤�≤105
- 1≤�,�≤109
Sample 1:
3 12 15 5 50 9 11
9 0 8
Explanation:
Test case 1: For �=6: lcm(12,6)−gcd(15,6)=12−3=9 which is the minimum value required.
Test case 2: For �=50: lcm(5,50)−gcd(50,50)=50−50=0 which is the minimum value required.
Test case 3: For �=1: lcm(9,1)−gcd(11,1)=9−1=8 which is the minimum value required.
SOLUTION
Here Discuss About Lcm hates Gcd Codechef Solution
SOLUTION
Lcm hates Gcd Codechef Solution
SOLUTION
Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer Then Follow US HERE and Join Telegram.
If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE