#include <cstdio>
typedef long long lint;
void solve(){
lint a;
int b,c;
scanf("%lld %d %d",&a,&b,&c);
int piv = 0;
lint ret = 0;
for (int i=0; i<a%c; i++) {
ret += (piv + b + c - 1) / c;
piv += b % c;
piv %= c;
// c번 반복하면 일정해짐
}
lint cnt2 = a/c;
lint ret2 = 0;
for (int i=0; i<c; i++) {
ret2 += (piv + b + c - 1) / c;
piv += b % c;
piv %= c;
// c번 반복하면 일정해짐
}
ret += ret2 * cnt2;
printf("%lld\n",ret);
}
int main(){
int t;
scanf("%d",&t);
for (int i=1; i<=t; i++) {
printf("Case #%d: ",i);
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |