一次性AC,用时15分钟。
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
int x=a,y=b,z=-1;
while(x%y!=0)
{
z=x%y;
x=y;
y=z;
}
return y;
}
int main()
{
// freopen("xxx.in","r",stdin);
// freopen("yyy.out","w",stdout);
int a,b;
cin >> a >> b;
cout << gcd(a,b);
// fclose(stdin);
// fclose(stdout);
return 0;
}