Submission #5875

# Submission time Handle Problem Language Result Execution time Memory
5875 2014-05-20T16:47:02 Z baneling100 새로운 달력 (GCJ12KOR_calendar) C++
25 / 25
0 ms 1088 KB
#include <stdio.h>

long long t, month, day, week, a[101], len, sum, ans, n;

void input(void)
{
    scanf("%lld %lld %lld",&month,&day,&week);
    len=sum=ans=0;
}

void process(void)
{
    long long i, x=day;

    while(1)
    {
        a[++len]=(x+week-1)/week;
        x+=(day%week);
        if(x>=day+week)
            x-=week;
        if(x==day)
            break;
    }
    for(i=1 ; i<=len ; i++)
        sum+=a[i];
    ans+=sum*(month/len);
    for(i=1 ; i<=month%len ; i++)
        ans+=a[i];
}

void output(void)
{
    printf("Case #%lld: %lld\n",n,ans);
}

int main(void)
{
    long long i;

    scanf("%lld",&t);
    for(i=1 ; i<=t ; i++)
    {
        n=i;
        input();
        process();
        output();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1088 KB Output is correct