GUPTA MECHANICAL

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

Wednesday 20 April 2022

Concurrent Lines Solution | CodeChef Problem Solution 2022

While playing in the plains, Chef found a point A with coordinates (X,Y).

Chef is interested in finding the number of straight lines passing through the point A such that their intercepts on both axes are positive integers.

Input Format

  • First and only line of input contains two integers X and Y - the coordinates of the point A.

Output Format

  • For each test case, print an integer - the number of lines satisfying the given conditions.

Constraints

  • 1X1012
  • 1Y1012

Sample Input 1 

3 2

Sample Output 1 

4

Explanation

There are 4 lines satisfying all the conditions. These lines are:

image

Sample Input 2 

1 2

Sample Output 2 

2

Explanation

There are 2 such lines, which are :

image

Sample Input 3 

28 206

Sample Output 3 

16

Explanation

There are 16 such lines.

No comments:

Post a Comment