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: 72ms
Memory: 1712kB
In contest: 1276

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <string>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int maxen=100010;
int gcd(int x,int y){
	return x==0?y:gcd(y%x,x);
}
void exchange(int x,int y){
	int t=x;
	x=y;
	y=t;
}
int main(){
    int n,q;
    scanf("%d %d",&n,&q);
    while(q--){
    	int s,t;
    	scanf("%d %d",&s,&t);
    	if(s>t){
    		exchange(s,t);
		}
		if(s==t+1||s==t-1){
			printf("1\n");
		}
		else{
				printf("2\n");
		}
	}
	return 0;
}