Skip to content

Commit 862f76a

Browse files
authored
[20251012] BOJ / G5 / 다이어트 / 이강현
1 parent a9aa71d commit 862f76a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
```java
2+
import java.util.*;
3+
import java.io.*;
4+
5+
public class Main{
6+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
static StringBuilder sb = new StringBuilder();
9+
static int G;
10+
11+
public static void main(String[] args) throws Exception {
12+
G = Integer.parseInt(br.readLine());
13+
List<Integer> results = new ArrayList<>();
14+
for (int b = 1; b * b <= G; b++) {
15+
if (G % b == 0) {
16+
int a = G / b;
17+
18+
if ((a + b) % 2 == 0) {
19+
int c = (a + b) / 2;
20+
int p = (a - b) / 2;
21+
22+
if (p >= 1) {
23+
results.add(c);
24+
}
25+
}
26+
}
27+
}
28+
29+
if (results.isEmpty()) {
30+
bw.write("-1");
31+
} else {
32+
Collections.sort(results);
33+
for (int weight : results) {
34+
bw.write(weight + "\n");
35+
}
36+
}
37+
38+
bw.close();
39+
}
40+
}
41+
```

0 commit comments

Comments
 (0)