-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlv1_thrMan.java
More file actions
45 lines (39 loc) · 1.11 KB
/
Copy pathlv1_thrMan.java
File metadata and controls
45 lines (39 loc) · 1.11 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
39
40
41
42
43
44
45
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.ArrayList;
public class Main{
public static void main(String args[]) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), ", ");
int[] arr;
ArrayList<Integer> myArr = new ArrayList<Integer>();
while (st.hasMoreTokens()){
int s = Integer.parseInt(st.nextToken());
myArr.add(s);
}
arr = new int[myArr.size()];
int idx = 0;
for (Integer i : myArr){
arr[idx] = i;
idx+=1;
}
Solution ans = new Solution();
System.out.println(ans.solution((arr)));
}
}
class Solution {
public int solution(int[] number) {
int answer = 0;
for(int i = 0; i < number.length; i++){
for (int j = i+1; j < number.length; j++){
for(int k = j+1; k < number.length; k++){
if (number[i]+number[j]+number[k] == 0){
answer+=1;
}
}
}
}
return answer;
}
}