-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathURI1087Queen.java
More file actions
38 lines (33 loc) · 1.09 KB
/
URI1087Queen.java
File metadata and controls
38 lines (33 loc) · 1.09 KB
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* See
* <a href="https://www.urionlinejudge.com.br/judge/en/problems/view/1087">Queen</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class URI1087Queen {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
String l;
int x1, x2, y1, y2;
while (!(l = in.readLine()).equals("0 0 0 0")) {
String[] P = l.split("\\s");
x1 = Integer.parseInt(P[0]);
y1 = Integer.parseInt(P[1]);
x2 = Integer.parseInt(P[2]);
y2 = Integer.parseInt(P[3]);
if (x1 == x2 && y1 == y2) {
out.println(0);
} else if (x1 == x2 || y1 == y2 || Math.abs(y2 - y1) == Math.abs(x2 - x1)) {
out.println(1);
} else {
out.println(2);
}
}
out.close();
}
}