Saleh127

CF 1401A

Aug 21st, 2020 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);cout.tie(0);
  7.  
  8. int t,n,k;
  9. cin>>t;
  10. while(t--)
  11. {
  12. cin>>n>>k;
  13. if(n==k) cout<<0<<endl;
  14. else if(n<k)
  15. {
  16. cout<<abs(n-k)<<endl;
  17. }
  18. else
  19. {
  20. if(n%2==0 && k%2==0) cout<<0<<endl;
  21. else if(n%2==1 && k%2==0) cout<<1<<endl;
  22. else if(n%2==0 && k%2==1) cout<<1<<endl;
  23. else if(n%2==1 && k%2==1) cout<<0<<endl;
  24. }
  25. }
  26.  
  27. return 0;
  28. }
  29.  
Add Comment
Please, Sign In to add comment