Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created October 9, 2019 07:44
Show Gist options
  • Save surinoel/9567ce823dfa05b075c18d147269aa6d to your computer and use it in GitHub Desktop.
Save surinoel/9567ce823dfa05b075c18d147269aa6d to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
for (int i = 1; ; i++) {
int n, m, k;
cin >> n >> m >> k;
if (n == 0 && m == 0 && k == 0) {
break;
}
long long ans = 0;
int d1 = k / m;
int d2 = k % m;
ans += d1 * n;
if (d2 >= n) {
ans += n;
}
else {
ans += d2;
}
cout << "Case " << i << ": " << ans << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment