Weird Subtraction Process
题意翻译
**【题目描述】**
两个数 $a$ 和 $b$ 要对它们做以下操作:
1. 如果 $a=0$ 或 $b=0$ ,结束程序。否则执行第 $2$ 步。
2. 如果 $a\geq2b$ ,把 $a$ 变为 $a-2b$ ,并返回第 $1$ 步。否则执行第 $3$ 步。
3. 如果 $b\geq 2 a$ ,把 $b$ 变为 $b-2a$,并返回第 $1$ 步。否则结束程序。
你需要将 $a,b$ 持续进行操作直到结束程序,输出结束程序时的 $a,b$。
**【输入格式】**
一行包含两个整数 $a$ 和 $b$($1 \leq a,b \leq 10^{18}$)。
【输出格式】
对 $a,b$ 持续进行操作直到结束程序,输出结束程序时的 $a,b$ 值,用空格隔开。
题目描述
You have two variables $ a $ and $ b $ . Consider the following sequence of actions performed with these variables:
1. If $ a=0 $ or $ b=0 $ , end the process. Otherwise, go to step $ 2 $ ;
2. If $ a>=2·b $ , then set the value of $ a $ to $ a-2·b $ , and repeat step $ 1 $ . Otherwise, go to step $ 3 $ ;
3. If $ b>=2·a $ , then set the value of $ b $ to $ b-2·a $ , and repeat step $ 1 $ . Otherwise, end the process.
Initially the values of $ a $ and $ b $ are positive integers, and so the process will be finite.
You have to determine the values of $ a $ and $ b $ after the process ends.
输入输出格式
输入格式
The only line of the input contains two integers $ n $ and $ m $ ( $ 1<=n,m<=10^{18} $ ). $ n $ is the initial value of variable $ a $ , and $ m $ is the initial value of variable $ b $ .
输出格式
Print two integers — the values of $ a $ and $ b $ after the end of the process.
输入输出样例
输入样例 #1
12 5
输出样例 #1
0 1
输入样例 #2
31 12
输出样例 #2
7 12
说明
Explanations to the samples:
1. $ a=12 $ , $ b=5 $ ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF946B/5a518872d8942914aef6c33d251688a64a8d6d74.png) $ a=2 $ , $ b=5 $ ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF946B/5a518872d8942914aef6c33d251688a64a8d6d74.png) $ a=2 $ , $ b=1 $ ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF946B/5a518872d8942914aef6c33d251688a64a8d6d74.png) $ a=0 $ , $ b=1 $ ;
2. $ a=31 $ , $ b=12 $ ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF946B/5a518872d8942914aef6c33d251688a64a8d6d74.png) $ a=7 $ , $ b=12 $ .