We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 01f0f30 + 23894a7 commit 2c2a4a5Copy full SHA for 2c2a4a5
1 file changed
JHLEE325/202602/20 BOJ G5 다이어트.md
@@ -0,0 +1,38 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
+ public static void main(String[] args) throws IOException {
7
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8
+ int G = Integer.parseInt(br.readLine());
9
10
+ long low = 1;
11
+ long high = 2;
12
+ boolean found = false;
13
+ StringBuilder sb = new StringBuilder();
14
15
+ while (true) {
16
+ long diff = high * high - low * low;
17
18
+ if (high - low == 1 && diff > G) break;
19
20
+ if (diff == G) {
21
+ sb.append(high).append("\n");
22
+ found = true;
23
+ high++;
24
+ } else if (diff < G) {
25
26
+ } else {
27
+ low++;
28
+ }
29
30
31
+ if (!found) {
32
+ System.out.println(-1);
33
34
+ System.out.print(sb.toString());
35
36
37
+}
38
+```
0 commit comments