[codeforces] 527A Playing with Paper

原题

简单的gcd

#include<cstdio>
#include<algorithm>
typedef long long ll;
using namespace std;
ll a,b,ans;

ll gcd(ll x,ll y)
{
    if (x<y) swap(x,y);
    if (y) ans+=x/y;
    return !y?x:gcd(y,x%y);
}

int main()
{
    scanf("%I64d%I64d",&a,&b);
    if (a<b) swap(a,b);
    if (a%b==0) printf("%I64d",a/b);
    else gcd(a,b),printf("%I64d",ans);
    return 0;
}
posted @ 2017-11-30 16:43  Mrha  阅读(109)  评论(0编辑  收藏  举报