• toc {:toc}

문제 ν™•μΈν•˜κΈ°

풀이

μ—°μ†ν•˜λŠ” P일 쀑 L일 λ™μ•ˆλ§Œ μ‚¬μš©ν•  수 μžˆλŠ” κ²½μš°μ— μ΅œλŒ€λ‘œ μ‚¬μš©ν•˜κΈ° μœ„ν•΄μ„œλŠ” VμΌμ—μ„œ μ΅œλŒ€ν•œ 연속할 수 μžˆμ„ 만큼 μ—°μ†ν•΄μ„œ μ‚¬μš©ν•˜κ³  λ‚˜λ¨Έμ§€λ₯Ό κ³ λ €ν•΄μ•Ό ν•œλ‹€.

예λ₯Ό λ“€λ©΄, L, P, Vκ°€ 5, 8, 20 인 경우 8일둜 2번 λŠμ„ 수 있고, 2번 λͺ¨λ‘ 5일 μ‚¬μš©ν•  수 μžˆλ‹€. 이후 20μΌμ—μ„œ 16일은 μ œμ™Έλ˜μ—ˆκΈ°μ— 4일이 λ‚¨λŠ”λ‹€. 이 경우 μ‚¬μš©ν•  수 μžˆλŠ” 5일보닀 μž‘κΈ° λ•Œλ¬Έμ— 4일을 λͺ¨λ‘ μ‚¬μš©ν•  수 μžˆλ‹€. λ§Œμ•½, μ‚¬μš©ν•  수 μžˆλŠ” 일이 남은 일보닀 더 적닀면 μ‚¬μš©ν•  수 μžˆλŠ” 일만 μ‚¬μš©ν•  수 μžˆλ‹€.

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 
    int L, P, V, share=0, rem=0, res=0, i=1;
 
    while(true){
        res = 0;
        cin >> L >> P >> V;
 
        if(L == 0 && P == 0 && V == 0) break;
 
        share = V / P;
        rem = V % P;
 
        res += share * L;
 
        if(L > rem){
            res += rem;
        }
        else{
            res += L;
        }
 
        printf("Case %d: %d\n", i, res);
        i++;
    }
 
    return 0;
}