Shortest Way
Practice
3.7 (77 votes)
Mathematics
Open
Approved
Easy Medium
Mathamatics
Problem
50% Success 6320 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

See Russian Translation

The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem.

The problem states:

Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations.

There are two types of operations you can use:

1.) If the pair is ( x , y ) then change it to ( x+y, y )

2.) If the pair is ( x , y ) then change it to ( x, x+y )

It is guaranteed that a and b are co-prime .

Input:

The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively.

Output:

Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case.

Constraints:

1 <= T <=10

1<= a,b <=1018

a and b are co-primes

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
3 votes
Tags:
MathematicsApprovedSimple-mathEasy-MediumMathematicsMathamatics
Points:30
9 votes
Tags:
Basic MathAlgorithmsMath
Points:30
13 votes
Tags:
Basic MathEasy-MediumMathematicsMathematics