Skip to content

Commit e38b732

Browse files
committed
[level 1] Title: 콜라 문제, Time: 0.15 ms, Memory: 88.2 MB -BaekjoonHub
1 parent 6ca3c0c commit e38b732

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

프로그래머스/1/132267. 콜라 문제/README.md

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

55
### 성능 요약
66

7-
메모리: 85.8 MB, 시간: 21.60 ms
7+
메모리: 88.2 MB, 시간: 0.15 ms
88

99
### 구분
1010

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

1717
### 제출 일자
1818

19-
2025년 05월 07일 17:49:50
19+
2025년 05월 07일 17:57:47
2020

2121
### 문제 설명
2222

프로그래머스/1/132267. 콜라 문제/콜라 문제.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ class Solution {
22
static int cnt = 0;
33

44
public int solution(int a, int b, int n) {
5-
recur(a,b,n);
5+
// //1. 재귀함수 이용
6+
// recur(a,b,n);
7+
8+
//2. 일반 반복문 이용
9+
while (n >= a) { // 남은 병이 a보다 크거나 같을 동안 계속 교환을 반복
10+
int x = n / a * b;
11+
int y = n % a;
12+
cnt += x;
13+
n = x + y;
14+
}
15+
616
return cnt;
717
}
818

@@ -15,7 +25,6 @@ void recur(int a, int b, int n){
1525
int y = n % a; //나머지
1626
cnt+=x;
1727

18-
System.out.println(x + " " + y);
1928
recur(a, b, x+y);
2029
}
2130
}

0 commit comments

Comments
 (0)