fork(7) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. uint64_t square(uint64_t x)
  5. {
  6. return x * x;
  7. }
  8.  
  9. int main()
  10. {
  11. int T;
  12. cin >> T; //no of test cases
  13. while(T--){
  14. uint64_t x, y;
  15. cin >> x >> y;
  16. if(x%2==0 && y%2!=0 && y< x){
  17. cout << fixed <<((x*x)-y)+1 << "\n";
  18. }else if(x%2==0 && y%2!=0 && y>x){
  19. cout << fixed << ((y*y)-x)+1 << "\n";
  20. }else if(x%2==0 && y%2==0 && y<x){
  21. cout << fixed << ((y*y)-x)+1 << "\n";
  22. }else if(x%2==0 && y%2==0 && y>x){
  23. cout << fixed << ((square((y*y)-1))+x)-1 << "\n";
  24. }else if(x%2!=0 && y%2==0 && y<x){
  25. cout << fixed << ((y*y)+x)-1 << "\n";
  26. }else if(x%2!=0 && y%2==0 && y>x){
  27. cout << fixed << (square((y-1)))+x << "\n";
  28. }else if(x%2!=0 && y%2!=0 && y<x){
  29. cout << fixed << (square((x-1)))+y << "\n";
  30. }else if(x%2!=0 && y%2!=0 && y>x){
  31. cout << fixed << ((y*y)-x)+1 << "\n";
  32. }
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5476KB
stdin
1 689913499 770079066
stdout
593021767041187724