300 - Maya Calendar
Moderator: Board moderators
300 - Maya Calendar
This works for all my test cases. Anyone know of any special tricks to this problem?
[cpp]#include <cstdio>
#include <cstring>
int ResolveMonth (char P[100])
{
char X[19][10]={"pop","no","zip","zotz","tzec","xul",
"yoxkin","mol","chen","yax","zac","ceh",
"mac","kankin","muan","pax","koyab","cumhu",
"uayet"};
int i;
for(i=0;i<19;i++)
{
if(strcmp(P,X)==0)
return i;
}
return -1;
}
void main()
{
int i,j,k,N,n,d,y;
char M[100];
char X[20][10]={"imix","ik","akbal","kan","chicchan",
"cimi","manik","lamat","muluk","ok",
"chuen","eb","ben","ix","mem","cib",
"caban","eznab","canac","ahau"};
scanf("%d",&N);
for(n=0;n<N;n++)
{
scanf("%d.%s%d",&d,&M,&y);
d+=ResolveMonth(M)*20+y*365;
y=d/260;
d%=260;
strcpy(M,X[d%20]);
d%=13;
d++;
printf("%d %s %d\n",d,M,y);
}
}[/cpp]
[cpp]#include <cstdio>
#include <cstring>
int ResolveMonth (char P[100])
{
char X[19][10]={"pop","no","zip","zotz","tzec","xul",
"yoxkin","mol","chen","yax","zac","ceh",
"mac","kankin","muan","pax","koyab","cumhu",
"uayet"};
int i;
for(i=0;i<19;i++)
{
if(strcmp(P,X)==0)
return i;
}
return -1;
}
void main()
{
int i,j,k,N,n,d,y;
char M[100];
char X[20][10]={"imix","ik","akbal","kan","chicchan",
"cimi","manik","lamat","muluk","ok",
"chuen","eb","ben","ix","mem","cib",
"caban","eznab","canac","ahau"};
scanf("%d",&N);
for(n=0;n<N;n++)
{
scanf("%d.%s%d",&d,&M,&y);
d+=ResolveMonth(M)*20+y*365;
y=d/260;
d%=260;
strcpy(M,X[d%20]);
d%=13;
d++;
printf("%d %s %d\n",d,M,y);
}
}[/cpp]
300
I got wrong answer.
I can't find the wrong.
[c]#include <stdio.h>
#include <string.h>
long int mon,day,year;
long now;
int main()
{
char b[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int n;
int index;
void Input();
scanf("%d",&n);
printf("%d\n",n);
for(index=0;index<n;index++){
Input();
now=year*365+mon*20+day;
printf("%ld %s %ld\n",now%13+1,b[now%20],now/260);
}
return(0);
}
void Input()
{
char a[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char str[10];
int index;
scanf("%ld. %s %ld",&day,str,&year);
for(index=0;index<19;index++)
{
if(strcmp(str,a[index])==0)
{
mon=index;
break;
}
}
}[/c]
I can't find the wrong.
[c]#include <stdio.h>
#include <string.h>
long int mon,day,year;
long now;
int main()
{
char b[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int n;
int index;
void Input();
scanf("%d",&n);
printf("%d\n",n);
for(index=0;index<n;index++){
Input();
now=year*365+mon*20+day;
printf("%ld %s %ld\n",now%13+1,b[now%20],now/260);
}
return(0);
}
void Input()
{
char a[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char str[10];
int index;
scanf("%ld. %s %ld",&day,str,&year);
for(index=0;index<19;index++)
{
if(strcmp(str,a[index])==0)
{
mon=index;
break;
}
}
}[/c]
-
- A great helper
- Posts: 284
- Joined: Thu Feb 28, 2002 2:00 am
- Location: Germany
- Contact:
When I copied my codes from file to Outlook Express 5.
It cut my code like that:
[c]#include <stdio.h>
#include <string.h>
long int mon,day,year;
long now;
int main()
{
char
b[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","mulu
k","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int n;
int index;
void Input();
scanf("%d",&n);
printf("%d\n",n);
for(index=0;index<n;index++){
Input();
now=year*365+mon*20+day;
printf("%ld %s %ld\n",now%13+1,b[now%20],now/260);
}
return(0);
}
void Input()
{
char
a[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax",
"zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char str[10];
int index;
scanf("%ld. %s %ld",&day,str,&year);
for(index=0;index<19;index++)
{
if(strcmp(str,a[index])==0)
{
mon=index;
break;
}
}
}[/c]
It cut my code like that:
[c]#include <stdio.h>
#include <string.h>
long int mon,day,year;
long now;
int main()
{
char
b[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","mulu
k","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int n;
int index;
void Input();
scanf("%d",&n);
printf("%d\n",n);
for(index=0;index<n;index++){
Input();
now=year*365+mon*20+day;
printf("%ld %s %ld\n",now%13+1,b[now%20],now/260);
}
return(0);
}
void Input()
{
char
a[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax",
"zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char str[10];
int index;
scanf("%ld. %s %ld",&day,str,&year);
for(index=0;index<19;index++)
{
if(strcmp(str,a[index])==0)
{
mon=index;
break;
}
}
}[/c]
-
- New poster
- Posts: 38
- Joined: Mon Dec 09, 2002 1:53 pm
- Location: Poznan, Poland
WA 300
I think my program is write. Please anybody, check my code.If there is important input you have, send it. Below the code://@begin_of_source_code
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>=5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+1+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
else tyear=0;
total=total%260;
tmonth=total%13; if(tmonth==0) tmonth=13;
dayname=total%20; if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname-1]<<" "<<tyear<<endl;
}
}
return 0;
}
//@end_of_source_code
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>=5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+1+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
else tyear=0;
total=total%260;
tmonth=total%13; if(tmonth==0) tmonth=13;
dayname=total%20; if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname-1]<<" "<<tyear<<endl;
}
}
return 0;
}
//@end_of_source_code
-
- New poster
- Posts: 24
- Joined: Mon Feb 24, 2003 5:08 pm
Your counting of tmonth and dayname are wrong!
This code got AC:))
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
//else tyear=0;
total=total%260;
tmonth=total%13+1; //if(tmonth==0) tmonth=13;
dayname=total%20; //if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname]<<" "<<tyear<<endl;
}
}
return 0;
}
This code got AC:))
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
//else tyear=0;
total=total%260;
tmonth=total%13+1; //if(tmonth==0) tmonth=13;
dayname=total%20; //if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname]<<" "<<tyear<<endl;
}
}
return 0;
}
300 AC(PE)
Mr. pupirev,
This is surprising that my code is presentation error.There is also your code which is Accepted.Tell me the difference.The codes are below:
//@begin_of_source_code
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: --------------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
/*count=0;
while(count++<n)
{
cin>>day[count]>>dot>>month[count]>>year[count];
}*/
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>=5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+1+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total%260==0) tyear=(total/260)-1;
else tyear=total/260;
total=total%260;
tmonth=total%13; if(tmonth==0) tmonth=13;
dayname=total%20; if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname-1]<<" "<<tyear<<endl;
}
}
return 0;
}
//@end_of_source_code
BUT THE CODE BELOW IS ACCEPTED.PLEASE TELL ME WHY?
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
else tyear=0;
total=total%260;
tmonth=total%13+1; //if(tmonth==0) tmonth=13;
dayname=total%20; //if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname]<<" "<<tyear<<endl;
}
}
return 0;
}
This is surprising that my code is presentation error.There is also your code which is Accepted.Tell me the difference.The codes are below:
//@begin_of_source_code
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: --------------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
/*count=0;
while(count++<n)
{
cin>>day[count]>>dot>>month[count]>>year[count];
}*/
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>=5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+1+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total%260==0) tyear=(total/260)-1;
else tyear=total/260;
total=total%260;
tmonth=total%13; if(tmonth==0) tmonth=13;
dayname=total%20; if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname-1]<<" "<<tyear<<endl;
}
}
return 0;
}
//@end_of_source_code
BUT THE CODE BELOW IS ACCEPTED.PLEASE TELL ME WHY?
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
else tyear=0;
total=total%260;
tmonth=total%13+1; //if(tmonth==0) tmonth=13;
dayname=total%20; //if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname]<<" "<<tyear<<endl;
}
}
return 0;
}