-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddone.java
More file actions
27 lines (26 loc) · 776 Bytes
/
addone.java
File metadata and controls
27 lines (26 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.awt.Point;
public class addone {
static int mod=(int)1e9+7;
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
StringBuilder sb=new StringBuilder();
while (t-->0){
int a=sc.nextInt(),b=sc.nextInt();
if (a==b) sb.append(0+"\n");
else if (a-b<0){
if ((b-a)%2==1){
sb.append(1+"\n");
}else sb.append(2+"\n");
}else {
if ((a-b)%2==0){
sb.append(1+"\n");
}else sb.append(2+"\n");
}
}
System.out.println(sb);
}
}