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

#include<stdio.h>
int gcd(int i,int j){
	int k;
	while(i%j!=0){
		i=i%j;
		k=i;
		i=j;
		j=k;	
	}
	return j;
}
int main(){
	int n,q;
	scanf("%d %d",&n,&q);
	while(q--){
		int s,t;
		scanf("%d %d",&s,&t);
		int k=gcd(s,t);
		if(k<=2)
		printf("%d\n",k);
		else
		printf("2\n");
	}
	return 0;
}