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