Start: Jun, 28, 2019 08:42:00
2019杭州师范大学第一届程序设计竞赛新生赛
End: Jun, 28, 2019 11:42:00
Contest has ended!
Time elapsed: 03:00:00
Time remaining: 00:00:00

Problem_ID: D
Result: Accepted
Time: 78ms
Memory: 1712kB
In contest: 1276

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <bits/stdc++.h>
using namespace std;
int gcd(int n,int m)
{
	return m == 0 ? n : gcd(m,n%m) ;
}
int main(int argc, char const *argv[])
{
	int n , k ;
	cin >> n >> k ;
	int a,b ;
	for(int i = 0 ; i < k ; ++ i)
	{
		scanf("%d %d",&a,&b) ;
		if(gcd(a,b) == 1)
			printf("1\n") ;
		else
			printf("2\n") ;
	}
	return 0;
}