2014-08-22

题意:

  (有中文版题目。。)

   就是两种历法的转换

思路:

  把两种历法的细节了解了就很简单了

  Haab历法一年365,Tzolkin一年260天

  先求出总天数sumDay,然后sumDay/260就是Tzolkin历的年份

  T历的天名称20一循环,我们只需建立名称与1-20的关系就行,对20取模即可

  T历的天数字同理可得到

  (注意输入输出格式!)

代码:

  

 //Memory Time
//352K 0MS #include <stdio.h> int getHmonth(char *Hmonth){
int i,asciiSum=;
for(i=;Hmonth[i];i++){
asciiSum+=Hmonth[i];
}
//将H历每个月份所含字母的ascii码求和,利用swich语句得到对应第几个月(注意从0开始的)
switch(asciiSum)
{
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
case :
return ;
}
}
int main()
{
char Tday[][]={"ahau","imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int i,n;
scanf("%d",&n);
printf("%d\n",n);
int sumDay,Hyear,Hday,hMonthNum;
char Hmonth[];
for(i=;i<n;i++){
scanf("%d. %s %d",&Hday,Hmonth,&Hyear);
hMonthNum=getHmonth(Hmonth);
sumDay=*Hyear+Hday+hMonthNum*;
printf("%d %s %d\n",sumDay%+,Tday[sumDay%+],sumDay/);
}
return ;
}

PS:注意下一些"+1"之类的细节

05-06 12:08