Educational Codeforces Round 39 B - Weird Subtraction Process
2018-03-19 16:41
543 查看
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
#define kuaidian ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100 + 7, maxd = 1e5 + 7;
const int mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
ll a, b;
int main() {
kuaidian
cin >> a >> b;
int f = 1;
while(1) {
if(a == 0 || b == 0) {
break;
}
if(a >= b*2) {
a %= b*2;
} else if(b >= a*2) {
b %= a*2;
} else break;
}
cout << a << " " << b;
return 0;
}
#include<algorithm>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
#define kuaidian ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100 + 7, maxd = 1e5 + 7;
const int mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
ll a, b;
int main() {
kuaidian
cin >> a >> b;
int f = 1;
while(1) {
if(a == 0 || b == 0) {
break;
}
if(a >= b*2) {
a %= b*2;
} else if(b >= a*2) {
b %= a*2;
} else break;
}
cout << a << " " << b;
return 0;
}
相关文章推荐
- Educational Codeforces Round 39 (Rated for Div. 2) B. Weird Subtraction Process
- Educational Codeforces Round 39 Editorial B(Euclid算法,连续-=与%=的效率)
- Educational Codeforces Round 39 (Rated for Div. 2) D. Timetable(动态规划)
- Educational Codeforces Round 39 (Rated for Div. 2) C. String Transformation
- Educational Codeforces Round 2 D - Area of Two Circles' Intersection(两圆交面积)
- Educational Codeforces Round 39 (Rated for Div. 2)D. Timetable(dp)
- Educational Codeforces Round 2 D. Area of Two Circles' Intersection
- Educational Codeforces Round 39 (Rated for Div. 2) E Largest Beautiful Number
- Educational Codeforces Round 39: F. Fibonacci String Subsequences(区间DP)
- Educational Codeforces Round 39 C - String Transformation
- Educational Codeforces Round 39 (Rated for Div. 2) codeforces946 A.Partition B.Weird Subtraction Process C.String Transformation
- Educational Codeforces Round 39 (Rated for Div. 2) D. Timetable (背包)
- Educational Codeforces Round 39 (Rated for Div. 2) 946E E. Largest Beautiful Number
- Educational Codeforces Round 2D. Area of Two Circles' Intersection(计算几何+圆相交的面积)
- Educational Codeforces Round 39 (Rated for Div. 2) G
- Educational Codeforces Round 39 (Rated for Div. 2)(A-D)(水题 + 模拟 + 贪心模拟 + DP)
- Educational Codeforces Round 39: G. Almost Increasing Array(LIS)
- Educational Codeforces Round 39
- Educational Codeforces Round 39: E. Largest Beautiful Number
- Educational Codeforces Round 39 (Rated for Div. 2)