-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsquare.java
42 lines (27 loc) · 1.25 KB
/
square.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.io.*;
import java.util.*;
import java.lang.Integer;
public class square {
public static void main(String[] args) throws IOException {
// write your code here
BufferedReader f = new BufferedReader(new FileReader("square.in"));
// input file name goes above
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("square.out")));
StringTokenizer st = new StringTokenizer(f.readLine());
int onexone = Integer.parseInt(st.nextToken());
int oneyone = Integer.parseInt(st.nextToken());
int onextwo = Integer.parseInt(st.nextToken());
int oneytwo = Integer.parseInt(st.nextToken());
st = new StringTokenizer(f.readLine());
int twoxone = Integer.parseInt(st.nextToken());
int twoyone = Integer.parseInt(st.nextToken());
int twoxtwo = Integer.parseInt(st.nextToken());
int twoytwo = Integer.parseInt(st.nextToken());
int leftx = Math.min(onexone,twoxone);
int rightx = Math.max(onextwo,twoxtwo);
int lefty = Math.min(oneyone,twoyone);
int righty = Math.max(oneytwo,twoytwo);
out.println(Math.max(rightx-leftx,righty-lefty)*Math.max(rightx-leftx,righty-lefty));
out.close();
}
}