Hide

Problem D
Early Termination

Languages en is
/problems/earlytermination/file/statement/en/img-0001.png
Is this...?

You are given non-negative integers a,b,k and are to implement Euclid’s algorithm with inputs a,b but terminate it as soon as a,bk.

Input

The first and only line of input contains non-negative integers a,b,k1018 separated by a space. We also have a,b1.

Output

Print a,b separated by a space after Euclid’s algorithm has been run until a,bk. Print the larger number first.

Sample Input 1 Sample Output 1
73 27 73
8 3
Hide

Please log in to submit a solution to this problem

Log in