fork download
  1. #include <bits/stdc++.h>
  2. #include <iostream>
  3. #include <vector>
  4. #include <set>
  5. #include <algorithm>
  6. #include <map>
  7. #include <cmath>
  8. using namespace std;
  9. typedef long long ll;
  10.  
  11. int main()
  12. {
  13. freopen("tabs.in", "r", stdin);
  14. //freopen(".out", "w", stdout);
  15.  
  16. ios_base::sync_with_stdio(false);
  17. cin.tie(0);
  18.  
  19. int t;
  20. cin>>t;
  21. while(t--)
  22. {
  23. int n,k;
  24. cin>>n>>k;
  25.  
  26. if(n==1)
  27. cout<<0<<"\n";
  28. else
  29. if(k==1||k==n)
  30. cout<<1<<"\n";
  31. else
  32. cout<<2<<"\n";
  33. } return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty