This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |