We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fcdb822 commit 25f3304Copy full SHA for 25f3304
1 file changed
2025-08-14/곽태근/백준-2018-수들의합.java
@@ -0,0 +1,36 @@
1
+import java.io.*;
2
+import java.util.*;
3
+
4
+public class Main{
5
6
+ public static void main(String[] args) throws IOException{
7
8
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9
+ BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
10
11
+ int N = Integer.parseInt(br.readLine());
12
13
+ int start_idx = 1;
14
+ int end_idx = 1;
15
+ int count = 1;
16
+ int sum = 1;
17
18
+ while(end_idx != N){
19
20
+ if(sum == N){
21
+ count++;
22
+ end_idx++;
23
+ sum = sum + end_idx;
24
+ }else if(sum>N){
25
+ sum = sum - start_idx;
26
+ start_idx++;
27
+ }else{
28
29
30
+ }
31
32
33
+ bw.write(count+"");
34
+ bw.flush();
35
36
+}
0 commit comments