-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.java
40 lines (32 loc) · 1.21 KB
/
Solution.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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args)throws IOException {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
for (int m = 1; m <= n; m++) {
int handShake = 0, num = 0;
int p = Integer.parseInt(br.readLine());
int[] x = new int[p];
if (p == 1 || p == 0) {
handShake = 0;
} else if (p == 2) {
handShake = 1;
} else {
/*for (int i = 0; i < x.length; i++) {
for (int j = (i + 1); j < x.length - 1; j++) {
handShake = (handShake + j);
}
}*/
for (int i = 1; i < x.length; i++) {
handShake += i;
}
}
System.out.println(handShake);
}
}
}