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

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

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string.h>
using namespace std;
typedef long long LL;

int gcd(int x,int y)
{
	if(y==0)
	{
		return x;
	}
	else
	{
		return gcd(y,x%y);
	}
}
int main()
{
	int n,q;
	scanf("%d%d",&n,&q);
	while(q--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(gcd(x,y)>=2)
		{
			printf("2\n");
		}
		else
		{
			printf("1\n");
		}
	}
	return 0;
}