Skip to content

Commit 25f3304

Browse files
authored
Create 백준-2018-수들의합.java
1 parent fcdb822 commit 25f3304

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
end_idx++;
29+
sum = sum + end_idx;
30+
}
31+
}
32+
33+
bw.write(count+"");
34+
bw.flush();
35+
}
36+
}

0 commit comments

Comments
 (0)