1100 Mars Numbers [模拟]

#include <bits/stdc++.h>
using namespace std;
#define maxn 55

string fir[]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
string sec[]={"#","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
map<string,int> m1,m2;
int main()
{
    string s;
    int n;
    cin>>n;
    for(int i=0;i<=12;i++){
        m1[fir[i]]=i;
        m2[sec[i]]=i;
    }
    getchar();
    while(n--)
    {
        getline(cin,s);
        if(isdigit(s[0]))
        {
            int tmp=0;
            for(int i=0;i<s.length();i++)
                tmp=tmp*10+s[i]-'0';
            if(tmp<=12)
                cout<<fir[tmp];
            else
            {
                int t1=tmp/13;
                int t2=tmp%13;
                cout<<sec[t1];
                if(t2)
                    cout<<" "<<fir[t2];
            }
        }
        else
        {
            if(s.length()==3)
            {
                if(m1.count(s)==1)
                    cout<<m1[s];
                else
                    cout<<m2[s]*13;
            }
            else
            {
                string s1,s2;
                s1=s.substr(0,3);
                s2=s.substr(4,3);
                cout<<m2[s1]*13+m1[s2];
            }
        }
        cout<<endl;
    }
}
View Code

猜你喜欢

转载自www.cnblogs.com/FTA-Macro/p/11440296.html