Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #define swap(x, y, t) ((t) = (x), (x) = (y), (y) = (t))
- using namespace std;
- int main () {
- int n, x1, y1, x2, y2, t, count = 1;
- cin >> n;
- while (n--){
- bool n = false;
- cin >> x1 >> y1 >> x2 >> y2;
- if (x1 + y1 > x2 + y2) swap(x1, x2, t), swap(y1, y2, t), n = true;
- int s1 = x1 + y1, s2 = x2 + y2, d = s2 - s1, sum = 0;
- if (d){
- for (int i = s1 + 1; i <= s2; i++) sum += i + 1;
- sum += (s1 - x1) - (s2 - x2);
- }
- else
- sum += x2 - x1;
- if (n) sum = -sum;
- cout << "Case " << count++ << ": " << sum << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment