[boj] (s5) 4796 캠핑

강신현·2022년 4월 1일
0

✅ 그리디

문제

링크

코드

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int num = 0;
    while(1){
        num ++;
        int L, P, V, cnt = 0;
        cin >> L >> P >> V;

        if(L == 0 && P == 0 && V == 0) break;

        cnt += V / P * L;
        if (V % P < L)
            cnt += V % P;
        else
            cnt += L;
        cout << "Case " << num << ": " << cnt << "\n";
    }

    

    return 0;
}
profile
땅콩의 모험 (server)

0개의 댓글