Submission #4357

#TimeUsernameProblemLanguageResultExecution timeMemory
4357ansol4328새로운 달력 (GCJ12KOR_calendar)C++98
25 / 25
0 ms1088 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...