웅재의 코딩세상

[프로그래머스] 콜라 문제 본문

코딩테스트/프로그래머스 - LV 1

[프로그래머스] 콜라 문제

웅드 2024. 2. 14. 16:34

 

  • 풀이
#include <string>
#include <vector>

using namespace std;

int solution(int a, int b, int n) {
    int answer = 0;
    while(n >= a){
        answer += (n/a)*b;
        int num = n%a;
        n = (n/a)*b + num;
    }
    return answer;
}
반응형