#include"cstdio" #include"iostream" #include"cstring" using namespace std; char H[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"}; char T[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"}; long get_h(int year,int day,char x[]) { long ans=0; ans+=year*365; for(int i=0;i<19;i++) if(!strcmp(x,H[i])) {ans+=i*20;break;} ans+=day; cout<<ans<<‘a‘<<endl; return ans; } void get_t(long temp) { long year,num,name; year=temp/260; temp%=260; name=temp%20; num=temp%13+1; printf("%ld %s %ld\n",num,T[name],year); } int main() { int day,year,T; char x[10]; scanf("%d",&T); cout<<T<<endl; while(T--) { long temp; scanf("%d. %s %d",&day,x,&year); temp=get_h(year,day,x); get_t(temp); } return 0; }
两种玛雅日期的转换,理解了题意并按照要求做就不会出错。有个需要注意的地方就是“uayet”这个月份容易被漏掉~~
时间: 2024-10-13 14:24:41