Skip to content

Commit ccea6fb

Browse files
committed
[level 2] Title: 숫자의 표현, Time: 1.91 ms, Memory: 54 MB -BaekjoonHub
1 parent d96bcd7 commit ccea6fb

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

프로그래머스/2/12924. 숫자의 표현/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 10.1 MB, 시간: 2.35 ms
7+
메모리: 54 MB, 시간: 1.91 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2024년 2월 1일 21:35:41
19+
2025년 05월 31일 22:07:20
2020

2121
### 문제 설명
2222

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution {
2+
public int solution(int n) {
3+
int answer = 0;
4+
5+
for (int i = 1; i <= n; i++) {
6+
int sum = 0;
7+
8+
// 현재 i부터 n까지 자연수를 더해가면서 합을 계산
9+
for (int j = i; j <= n; j++) {
10+
sum += j;
11+
12+
// 현재 i부터 n까지 자연수를 더해가면서 합을 계산
13+
if (sum == n) {
14+
answer++;
15+
break;
16+
}
17+
18+
// 합이 주어진 n보다 크면 내부 반복문 종료
19+
if (sum > n) break;
20+
}
21+
}
22+
23+
return answer;
24+
}
25+
}

0 commit comments

Comments
 (0)