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: 87ms
Memory: 1092kB
In contest: 1276

#include <stdio.h>
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}

int main(){
	int n,q,i,s,t;
	scanf("%d%d",&n,&q);
	getchar();
	for(i=0;i<q;++i){
		scanf("%d%d",&s,&t);
		getchar();
		if(gcd(s,t)>=2){
			printf("2");
		}else{
			printf("1");;
		}
		printf("\n");;
	}
	
	return 0;
}