注意超出了int的范围!
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
long long a,b;
scanf("%I64d%I64d",&a,&b);
if(a<b)
{
long long w=a;
a=b;
b=w;
}
long long s=0;
while(a%b)
{
s+=a/b;
long long m=max(b,a%b);
long long n=min(b,a%b);
a=m;
b=n;
}
printf("%I64d\n",s+a/b);
return 0;
}