Guest User

Untitled

a guest
Mar 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<iostream>
  2. #define swap(x, y, t) ((t) = (x), (x) = (y), (y) = (t))
  3. using namespace std;
  4.  
  5. int main () {
  6. int n, x1, y1, x2, y2, t, count = 1;
  7. cin >> n;
  8. while (n--){
  9. bool n = false;
  10. cin >> x1 >> y1 >> x2 >> y2;
  11. if (x1 + y1 > x2 + y2) swap(x1, x2, t), swap(y1, y2, t), n = true;
  12. int s1 = x1 + y1, s2 = x2 + y2, d = s2 - s1, sum = 0;
  13. if (d){
  14. for (int i = s1 + 1; i <= s2; i++) sum += i + 1;
  15. sum += (s1 - x1) - (s2 - x2);
  16. }
  17. else
  18. sum += x2 - x1;
  19. if (n) sum = -sum;
  20. cout << "Case " << count++ << ": " << sum << endl;
  21. }
  22. return 0;
  23. }
Add Comment
Please, Sign In to add comment