#include <stdio.h>
long long t, month, day, week, a[101], len, sum, ans;
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("%lld\n",ans);
}
int main(void)
{
long long i;
scanf("%lld",&t);
for(i=1 ; i<=t ; i++)
{
input();
process();
output();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1088 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1088 KB |
Output isn't correct |