We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3734a5a commit 9338026Copy full SHA for 9338026
1 file changed
1358/C/Main.java
@@ -0,0 +1,36 @@
1
+import java.util.Scanner;
2
+
3
+public class Main {
4
+ public static void main(String[] args) {
5
+ Scanner sc = new Scanner(System.in);
6
7
+ int t = sc.nextInt();
8
+ for (int tc = 0; tc < t; ++tc) {
9
+ int x1 = sc.nextInt();
10
+ int y1 = sc.nextInt();
11
+ int x2 = sc.nextInt();
12
+ int y2 = sc.nextInt();
13
14
+ System.out.println(solve(x1, y1, x2, y2));
15
+ }
16
17
+ sc.close();
18
19
20
+ static long solve(int x1, int y1, int x2, int y2) {
21
+ int xDiff = x2 - x1;
22
+ int yDiff = y2 - y1;
23
24
+ if (xDiff == 0 || yDiff == 0) {
25
+ return 1;
26
27
+ if (xDiff == 1) {
28
+ return yDiff + 1;
29
30
+ if (yDiff == 1) {
31
+ return xDiff + 1;
32
33
34
+ return xDiff + 1 + xDiff * (yDiff - 1L);
35
36
+}
0 commit comments