Maya Calendar POJ - 1008 (模擬)
阿新 • • 發佈:2018-12-24
簡述
注意260天的情況,這個地方還是0年
程式碼
#include <iostream> #include <map> #include <sstream> using namespace std; map<string,int> bk; map<int,string> bk1; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); bk["pop"]=1;bk["no"]=2;bk["zip"]=3;bk["zotz"]=4; bk["tzec"]=5;bk["xul"]=6;bk["yoxkin"]=7;bk["mol"]=8; bk["chen"]=9;bk["yax"]=10;bk["zac"]=11;bk["ceh"]=12; bk["mac"]=13;bk["kankin"]=14;bk["muan"]=15;bk["pax"]=16; bk["koyab"]=17;bk["cumhu"]=18;bk["uayet"]=19; bk1[1]="imix";bk1[2]="ik";bk1[3]="akbal";bk1[4]="kan"; bk1[5]="chicchan";bk1[6]="cimi";bk1[7]="manik";bk1[8]="lamat"; bk1[9]="muluk";bk1[10]="ok";bk1[11]="chuen";bk1[12]="eb";bk1[13]="ben"; bk1[14]="ix";bk1[15]="mem";bk1[16]="cib";bk1[17]="caban";bk1[18]="eznab"; bk1[19]="canac";bk1[20]="ahau"; int n; cin>>n; cout<<n<<"\n"; cin.get(); while(n--) { string a; getline(cin,a); string t=""; for(int i=0;i<a.size();i++) if(isdigit(a[i])) t+=a[i]; else break; int l=t.size(); l+=2; stringstream s; s<<t; int day; s>>day; day+=1; t=""; for(int i=l;;i++) if(isalpha(a[i])) t+=a[i]; else break; l+=t.size(); //cout<<t<<"\n"; int month=bk[t]; t=""; l+=1; for(int i=l;i<a.size();i++) if(isdigit(a[i])) t+=a[i]; stringstream s1; s1<<t; int year; s1>>year; //cout<<year<<" "<<month<<" "<<day<<"\n"; int sum=year*365+(month-1)*20+day; int ty; if(sum==0) ty=0; else ty=(sum-1)/260; int yu=(sum-1)%260+1; int td=(yu-1)%13+1; int st=(yu-1)%20+1; //cout<<st<<"\n"; cout<<td<<" "<<bk1[st]<<" "<<ty<<"\n"; } }