Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit a7477d7

Browse files
authored
Add files via upload
1 parent 593ed06 commit a7477d7

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

square.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
public class square {
5+
6+
public static int GetInt(StringTokenizer st) throws IOException{
7+
return Integer.parseInt(st.nextToken());
8+
9+
}
10+
private static BufferedReader f;
11+
public static int[] sort(int x,int y) {
12+
int[] output= {y,x};
13+
if(x>y) {
14+
output[0]=x;
15+
output[1]=y;
16+
}
17+
for(int i:output) {
18+
System.out.print(i+" ");
19+
}
20+
System.out.println();
21+
return output;
22+
}
23+
public static int solve(int x1,int y1,int x2,int y2,int X1,int Y1,int X2,int Y2) {
24+
int[] a,b,c,d,e,f,g,h;
25+
int MINX,MINY,MAXX,MAXY;
26+
a=sort(x1,x2);
27+
b=sort(X1,X2);
28+
c=sort(y1,y2);
29+
d=sort(Y1,Y2);
30+
e=sort(a[0],b[0]);
31+
f=sort(c[0],d[0]);
32+
g=sort(a[1],b[1]);
33+
h=sort(c[1],d[1]);
34+
MAXX=e[0];
35+
MAXY=f[0];
36+
MINY=h[1];
37+
MINX=g[1];
38+
int x,y;
39+
x=MAXX-MINX;
40+
y=MAXY-MINY;
41+
if(x>y) {
42+
return x*x;
43+
}else {
44+
return y*y;
45+
}
46+
47+
48+
}
49+
50+
public static void main(String[] args) throws IOException {
51+
52+
f = new BufferedReader(new FileReader("square.in"));
53+
StringTokenizer st1;
54+
StringTokenizer st2;
55+
st1=new StringTokenizer(f.readLine());
56+
st2=new StringTokenizer(f.readLine());
57+
PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("square.out")));
58+
pw.print(solve(GetInt(st1),GetInt(st1),GetInt(st1),GetInt(st1),GetInt(st2),GetInt(st2),GetInt(st2),GetInt(st2)));
59+
pw.close();
60+
f.close();
61+
62+
63+
}
64+
65+
}

0 commit comments

Comments
 (0)