水题 Codeforces Round #296 (Div. 2) A. Playing with Paper

 

题目传送门

 1 /*  2  水题  3  a或b成倍的减  4 */  5 #include <cstdio>  6 #include <iostream>  7 #include <algorithm>  8 #include <cmath>  9 #include <cstring> 10 #include <string> 11 #include <map> 12 #include <set> 13 #include <vector> 14 #include <set> 15 using namespace std; 16 17 const int MAXN = 1e6 + 10; 18 const int INF = 0x3f3f3f3f; 19 20 int main(void) 21 { 22 //freopen ("A.in", "r", stdin); 23 24 long long a, b; 25 26 while (~scanf ("%I64d%I64d", &a, &b)) 27  { 28 long long cnt = 1; 29 while (a != b && a!=0 && b!=0) 30  { 31 if (a > b) 32  { 33 long long x = a / b; 34 cnt += x; 35 a -= x * b; 36 37  } 38 else if (a < b) 39  { 40 long long x = b / a; 41 cnt += x; 42 b -= a * x; 43  } 44  } 45 46 printf ("%I64d\n", cnt-1); 47  } 48 49 50 return 0; 51 }

 

你可能感兴趣的:(codeforces)