POJ 1008 Maya Calendar
题目:http://poj.org/problem?id=1008
玛雅人历法的一道题。
不愧是POJ,看上去的一道水题都能这么恶心...这题WA了好多次
最早是漏了uayet 这个月份
然后是一年的最后一天当成了下一年
下面这组数据:
输入:4. uayet 259 输出:13 ahau 364
只要过了这组数据就没问题了...
#include <iostream> #include <string> #include <stdio.h> #include <cstdlib> using namespace std; string hname[19]={ "pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"}; string tname[20]={ "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; int main() { int n; cin>>n; cout<<n<<endl; for (int i = 0; i < n; i++) { int daynum=0; int hday,hyear; char t; string hmonth; cin>>hday; cin>>t; cin>>hmonth>>hyear; if(hyear>0) daynum+=hyear*365; for (int j = 0; j < 19; j++) { if(hmonth==hname[j]) { daynum+=j*20; break; } } daynum+=(hday+1); int tday=daynum%20; cout<<(daynum-1)%13+1<<" "<<tname[(daynum-1)%20]<<" "<<(daynum-1)/260<<endl; } return 0; }