GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday 10 June 2022

[Solution] Possible GCD CodeChef Solution | CodeChef Problem Solution 2022

Chef has two distinct positive integers A and B.

Chef wonders how many distinct values are possible for the expression gcd(A+X,B+X), where X can take any non-negative integer value.

Help Chef find this value.

Here, gcd stands for Greatest Common Divisor.

Input Format

  • The first line contains a single integer T — the number of test cases. Then the test 
Solution Click Below:-  CLICK HERE




    • cases follow.
    • The first and only line of each test case contains two distinct space separated integers A and B.

    Output Format

    For each testcase, output the number of distinct values of the expression gcd(A+X,B+X),









     where X can take any non-negative integer value.

    Constraints

    • 1T1000
    • 1A,B109

    No comments:

    Post a Comment