北大的ACM题库中1008题为什么提交时总是Wrong Answer,测试时的程序可以通过啊,代码如下,有劳大虾救助

2024年11月30日 05:39
有1个网友回答
网友(1):

#include
using namespace std;
#include
int TransHaab(char *NofM)
{
if(strcmp(NofM,"pop")==0)
return 1;
if(strcmp(NofM,"no")==0)
return 2;
if(strcmp(NofM,"zip")==0) // "zip" 中间多了个空格
return 3;
if(strcmp(NofM,"zotz")==0)
return 4;
if(strcmp(NofM,"tzec")==0)
return 5;
if(strcmp(NofM,"xul")==0)
return 6;
if(strcmp(NofM,"yoxkin")==0)
return 7;
if(strcmp(NofM,"mol")==0)
return 8;
if(strcmp(NofM,"chen")==0)
return 9;
if(strcmp(NofM,"yax")==0)
return 10;
if(strcmp(NofM,"zac")==0)
return 11;
if(strcmp(NofM,"ceh")==0)
return 12;
if(strcmp(NofM,"mac")==0)
return 13;
if(strcmp(NofM,"kankin")==0)
return 14;
if(strcmp(NofM,"muan")==0)
return 15;
if(strcmp(NofM,"pax")==0)
return 16;
if(strcmp(NofM,"koyab")==0)
return 17;
if(strcmp(NofM,"cumhu")==0)
return 18;
if(strcmp(NofM,"uayet")==0)
return 19;

}
void TransTzd(int NofD)
{
switch(NofD)
{
case 1:cout<<"imix";break;
case 2:cout<<"ik";break;
case 3:cout<<"akbal";break;
case 4:cout<<"kan";break;
case 5:cout<<"chicchan";break;
case 6:cout<<"cimi";break;
case 7:cout<<"manik";break;
case 8:cout<<"lamat";break;
case 9:cout<<"muluk";break;
case 10:cout<<"ok";break;
case 11:cout<<"chuen";break;
case 12:cout<<"eb";break;
case 13:cout<<"ben";break;
case 14:cout<<"ix";break;
case 15:cout<<"mem";break;
case 16:cout<<"cib";break;
case 17:cout<<"caban";break;
case 18:cout<<"eznab";break;
case 19:cout<<"canac";break;
case 20:cout<<"ahau";break;

}
}
int daycount(int DNum,char *NofM,int Hyears)
{
long month,counts;
month=TransHaab(NofM);
counts=Hyears*365+(month-1)*20+DNum+1;
return counts;

}
void TransCalender(long dcount)
{
long years,num,mod,NofD;
years=(dcount-1)/260; // 忘记-1, 这是硬伤啊
mod=dcount%260;
num=mod%13;
if(num==0)
num=13;
NofD=mod%20;
if(NofD==0)
NofD=20;
cout<TransTzd(NofD);
cout<<' '<
}

int main()
{
long m,DNum,Hyears;
char temp;
static char NofM[15];
long dcount[60000];
cin>>m;
for(int i=0;i {
cin>>DNum>>temp>>NofM>>Hyears;
dcount[i]=daycount(DNum,NofM,Hyears);
}
cout< for(int k=0;k {
TransCalender(dcount[k]);
}
return 0;
}