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