游客 Signup | Login
中文 | En

3118 - 最大公约数

求两个自然数M和N的最大公约数
求两个自然数M和N的最大公约数(M,N都在长整型范围内)

<br />

Input

输入一行,包括两个整数. 

Output

输出只有一行(这意味着末尾有一个回车符号),包括1个整数。 

Examples

Input

45 60

Output

15

Solution C++

#include<iostream>
using namespace std;
int main()
{
	int m,n,y;
	cin>>m>>n;
	while (n!=0)
	{
		y=m%n;
		m=n;
		n=y;
	}
	cout<<m;
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题