include stdafx include math include iostream using namespace std int i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "stdafx.h"
//#include "math.h"
#include <iostream>
using namespace std;
int f (int n, int m)
{
int n_k, n_k_1, n_k_2;
n_k_2= max(n,m);
n_k_1=min(n,m);
while ((n_k_2 - (int)(n_k_2/n_k_1) *n_k_1)!=0)
{
n_k= n_k_2 - (int)(n_k_2/n_k_1) *n_k_1;
n_k_2=n_k_1;
n_k_1=n_k;
}
return n_k_1;
}
void main()
{ int N,M;
cin>>N;
cin>>M;
cout<<f(N,M);
}