Greedy
V를 P씩 나누고 나뉜 것 안에서 L만큼 세어 총 일 수를 구하면 된다. 만약 마지막 부분, 즉 나머지가 L 보다 작거나 같다면 일 수에 나머지를 더하여 주고 아닌 경우 L을 일 수에 더한다.
#include <iostream>
using namespace std;
int l, p, v, ans;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int cnt = 1;
while (1) {
cin >> l >> p >> v;
if (l == 0 && p == 0 && v == 0) break;
int q = v / p;
int r = v % p > l ? l : v % p;
ans = q * l + r;
cout << "Case " << cnt << ": " << ans << "\n";
cnt++;
}
return 0;
}