-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHowManyPiecesOfLand.java
29 lines (25 loc) · 1.03 KB
/
HowManyPiecesOfLand.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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class HowManyPiecesOfLand {
private static final BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in));
private static BigInteger calculate(BigInteger v) {
BigInteger t1 = v.multiply(v.subtract(BigInteger.ONE))
.divide(BigInteger.valueOf(2));
BigInteger t2 = v.multiply(v.subtract(BigInteger.ONE))
.multiply(v.subtract(BigInteger.valueOf(2)))
.multiply(v.subtract(BigInteger.valueOf(3)))
.divide(BigInteger.valueOf(4 * 3 * 2));
return BigInteger.ONE.add(t2).add(t1);
}
public static void main(String[] args)
throws NumberFormatException, IOException {
int n = Integer.parseInt(reader.readLine().trim());
for (int i = 0; i < n; ++i) {
System.out.println(
calculate(new BigInteger(reader.readLine().trim())));
}
}
}