Advertisement
Salehisayev

FOR REVAN

Mar 9th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. # include <bits/stdc++.h>
  2. using namespace std;
  3. # define ll long long
  4. int main()
  5. {
  6. ll n,k,i,j,s = 0,x,y;
  7. cin >> n;
  8. for(i = 0; i < n; i++){
  9. cin >> x >> y;
  10. if(x == y){
  11. cout << x * x - x + 1 << endl;
  12. }
  13. if(x > y && !(x % 2)){
  14. cout << x * x - y + 1 << endl;
  15. }
  16. if (y > x && y % 2){
  17. cout << y * y - x + 1 << endl;
  18. }
  19. if(x > y && x % 2){
  20. cout << (x - 1) * (x - 1) + y << endl;
  21. }
  22. if(y > x && !(y % 2)){
  23. cout << (y - 1) * (y - 1) + x << endl;
  24. }
  25. }
  26. cout << endl;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement