首页 > 代码库 > POJ 1008 Maya Calendar

POJ 1008 Maya Calendar

Maya Calendar

思路:日历转换,仔细一点。

代码:

 

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
map<string,int>mp;
string a[19]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
string b[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;
    for(int i=0;i<19;i++)mp[a[i]]=i;
    cin>>n;
    cout<<n<<endl;
    while(n--)
    {
        int day,year;
        char doc;
        string month;
        cin>>day>>doc>>month>>year;
        //cout<<month<<endl;
        int t=year*365+mp[month]*20+day;
        int year1=t/260;
        string day1=b[t%20];
        int day2=t%13+1;
        cout<<day2<< <<day1<< <<year1<<endl;
    }
    return 0;
}

 

POJ 1008 Maya Calendar