Playground/자바문제집
[백준] 2018번
미숫가루설탕많이
2023. 4. 4. 22:42
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int count = 1, startIndex = 1, endIndex = 1, sum = 1;
while(endIndex != N) {
if (sum == N) {
count++;
endIndex++;
sum += endIndex;
} else if (sum > N) {
sum -= startIndex;
startIndex++;
} else {
endIndex++;
sum += endIndex;
}
}
System.out.println(count);
}
}