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<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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |