Submission #4357

# Submission time Handle Problem Language Result Execution time Memory
4357 2013-09-18T12:55:03 Z ansol4328 새로운 달력 (GCJ12KOR_calendar) C++
25 / 25
0 ms 1088 KB
#include<stdio.h>

int n;
long long m, md, wd, line;

int main()
{
    int i;
    long long a, b, c, gcd, k;

    scanf("%d",&n);
    for(i=1 ; i<=n  ; i++)
    {
        scanf("%lld %lld %lld",&m,&md,&wd);
        a=md%wd;
        b=wd;
        c=a%b;
        while(c!=0)
        {
            a=b;
            b=c;
            c=a%b;
        }
        gcd=b;
        k=wd/gcd;
        line=(m*md)/wd;
        line+=(m/k)*(k-1);
        line+=(m%k);
        printf("Case #%d: %lld\n",i,line);
    }
    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