-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboj_10448.java
More file actions
36 lines (32 loc) · 1.03 KB
/
boj_10448.java
File metadata and controls
36 lines (32 loc) · 1.03 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
package brute_force;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class boj_10448 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int[] triNum = new int[45];
for(int i = 1; i < 45; i++) {
triNum[i] = i * (i + 1) / 2;
}
for(int i = 0; i < N; i++) {
int n = Integer.parseInt(br.readLine());
int result = eureka(n, triNum);
System.out.println(result);
}
}
private static int eureka(int N,int[] triNum){
for(int j = 1; j < 45; j++) {
for (int k = 1; k < 45; k++) {
for (int z = 1; z < 45; z++) {
int sum = triNum[j] + triNum[k] + triNum[z];
if (sum == N) {
return 1;
}
}
}
}
return 0;
}
}