#include<stdio.h>
int main()
{
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		while(a!=b)
		{
		if(a>b)
			a=a-b;
		else
			b=b-a;
		}
		printf("%d\n",a);
	}
		return 0;
}

  

最大公约数


Time limit: 1000MS    Memory limit: 32768K 
Total Submit: 2875    Accepted: 1359 

给你两个数,求最大公约数。

每行输入两个数a,b。(0< a < 1000000, 0< b < 1000000 )。

每行输出最大公约数。

Sample Input

12 2 
1024 256
19 43

Sample Output

2
256
1

Source:_Bee_sharp
posted on 2011-11-20 17:03  C's  阅读(188)  评论(0)    收藏  举报