class Solution {
public int solution(int n) {
int answer = 0;
int start = 1;
int end = 1;
int sum = 1;
// 시작점, 끝점, 총합을 선언
while(true) {
if(sum<n) {
end++;
sum += end;
// 총합보다 적다면 끝점을 하나 뒤로해서 총합을 늘림
} else if(sum == n) {
answer++;
sum-=start;
start++;
// 총합과 같다면 answer+1을 한 뒤 시작점을 하나 뒤로 늘려 경우를 바꿈
} else if(sum>n) {
sum-=start;
start++;
// 총 합보다 크다면 시작점 하나 뒤로 이동하여 총 합을 줄임
}
if(start > n) break;
// 시작점이 N보다 크다면 반복 종료
}
return answer;
}
}
Start profiting from your traffic—sign up today! https://shorturl.fm/pWZ7j
Monetize your influence—become an affiliate today! https://shorturl.fm/QQ1x9
Unlock exclusive rewards with every referral—enroll now! https://shorturl.fm/ItUIZ
Monetize your traffic instantly—enroll in our affiliate network! https://shorturl.fm/lea8v
Share our link, earn real money—signup for our affiliate program! https://shorturl.fm/avBeN
Join our affiliate program and watch your earnings skyrocket—sign up now! https://shorturl.fm/rKSYe
Partner with us for generous payouts—sign up today! https://shorturl.fm/qRKPW
Monetize your traffic instantly—enroll in our affiliate network! https://shorturl.fm/wEnzk
Join our affiliate program today and start earning up to 30% commission—sign up now! https://shorturl.fm/8Z1wO
Join our affiliate program and watch your earnings skyrocket—sign up now! https://shorturl.fm/q6rll