Playing with Paper -CodeForces - 527A
2018-02-14 22:11
302 查看
题意:欧几里德算法求最大公约数
gcd(a,b)=gcd(a%b,b)
AC代码:
#include <iostream>
using namespace std;
long long sum;
long long gcd(long long a, long long b) {
if (b != 0)
sum += a / b;
return b == 0 ? a : gcd(b, a % b);
}
int main() {
long long a, b;
while (cin >> a >> b) {
sum = 0;
gcd(a, b);
cout << sum << endl;
}
return 0;
}
gcd(a,b)=gcd(a%b,b)
AC代码:
#include <iostream>
using namespace std;
long long sum;
long long gcd(long long a, long long b) {
if (b != 0)
sum += a / b;
return b == 0 ? a : gcd(b, a % b);
}
int main() {
long long a, b;
while (cin >> a >> b) {
sum = 0;
gcd(a, b);
cout << sum << endl;
}
return 0;
}
相关文章推荐
- 【codeforces 527A】Playing with Paper
- Playing with Paper (CodeForces - 527A)
- Codeforces_round296_Playing with Paper
- CF_527A_PlayingWithPaper
- 水题 Codeforces Round #296 (Div. 2) A. Playing with Paper
- D-codeforces527A- Playing with Paper
- CF Playing with Paper
- Codeforces Round #296 (Div. 2) -----A. Playing with Paper
- A-Playing with Paper
- Codeforces Round #296 (Div. 2)——A——Playing with Paper
- A. Playing with Paper
- A - Playing with Paper
- A. Playing with Paper
- Playing with String(codeforces 305E)
- 【数学基础01】Playing with Paper
- Playing with Paper
- codeforces--12.29--A. Playing with Dice
- CF527A:Playing with Paper——题解
- A. Playing with Paper
- [转自codeforces] How to come up with the solutions: techniques