fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7.  
  8. int t;
  9. cin>>t;
  10. while(t--) {
  11. long long int a,b;
  12. cin>>a>>b;
  13. if(a==b) {
  14. cout<<"0"<<endl;
  15. }
  16. else if(b>a) {
  17. if(abs(a-b)%2==1) {
  18. cout<<"1"<<endl;
  19. }
  20. else {
  21. cout<<"2"<<endl;
  22. }
  23. } else if(a>b) {
  24. if(abs(a-b)%2==0) {
  25. cout<<"1"<<endl;
  26. }
  27. else {
  28. cout<<"2"<<endl;
  29. }
  30. }
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 4448KB
stdin
5
2 3
10 10
2 4
7 4
9 3
stdout
1
0
2
2
1