Submission #5878

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
58782014-05-20 21:20:00kriii새로운 달력 (GCJ12KOR_calendar)C++98
25 / 25
0 ms1088 KiB
#include <stdio.h>
int T,C,GO[101],DA[101],END[101],LEN,CYC,ST;
long long M,D,W,ANS,S,SUM[101],CYS;
int main()
{
int T; scanf ("%d",&T); for (C=1;C<=T;C++){
scanf ("%lld %lld %lld",&M,&D,&W);
for (int i=0;i<W;i++){
GO[i] = (D + i) % W;
DA[i] = (D + i + W - 1) / W;
END[i] = -1; SUM[i] = 0;
}
S = 0; END[0] = 0; SUM[0] = DA[0];
while (1){
int E = GO[S];
if (END[E] != -1){
LEN = END[E] + 1;
CYC = END[S] - END[E] + 1;
CYS = SUM[S] + DA[E] - SUM[E];
ST = S;
break;
}
SUM[E] = SUM[S] + DA[E];
END[E] = END[S] + 1;
S = E;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...