forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.java
More file actions
29 lines (27 loc) · 949 Bytes
/
A.java
File metadata and controls
29 lines (27 loc) · 949 Bytes
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
import java.io.*;
import java.math.*;
import java.util.*;
public class A {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(new InputStreamReader(new FileInputStream("china.in")));
PrintWriter pw = new PrintWriter(new File("china.out"));
while (sc.hasNext()) {
BigInteger n = new BigInteger(sc.nextLine());
BigInteger TWO = BigInteger.valueOf(2);
if (n.mod(TWO).equals(BigInteger.ZERO)) {
BigInteger t = n.divide(TWO).subtract(BigInteger.ONE);
if (t.mod(TWO).equals(BigInteger.ZERO)) {
pw.println(t.subtract(BigInteger.ONE));
}
else {
pw.println(t);
}
}
else {
pw.println(n.divide(TWO));
}
}
pw.close();
sc.close();
}
}