Submission #14439

# Submission time Handle Problem Language Result Execution time Memory
14439 2015-05-16T06:24:01 Z gs14004 새로운 달력 (GCJ12KOR_calendar) C++14
25 / 25
0 ms 1084 KB
#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