#include <cstdio>
#include <iostream>
#include <string>
#include <map>
using namespace std;
string dw[13] = {"tret","jan","feb","mar","apr","may","jun","jly","aug",
"sep","oct","nov","dec"};
string gw[13] = {"tret","tam","hel","maa","huh","tou","kes","hei",
"elo","syy","lok","mer","jou"};
string numtostr[170];
map<string,int> strtonum;
void init(){
for(int i=0; i<13; i++){
numtostr[i] = dw[i];
strtonum[dw[i]] = i;
numtostr[i*13] = gw[i];
strtonum[gw[i]] = i*13;
}
for(int i=1; i<13; i++){
for(int j=1; j<13; j++){
numtostr[i*13 + j] = gw[i] + " " + dw[j];
strtonum[numtostr[i*13 + j]] = i*13 + j;
}
}
}
int main(){
init();
int n;
cin >> n;
getchar();
for(int i=0; i<n; i++){
string s;
getline(cin,s);
if(s[0]>='0' && s[0]<='9'){
int num = 0;
for(int j=0; j<s.length(); j++){
num = num*10 + s[j]-'0';
}
cout << numtostr[num] << endl;
}else{
cout << strtonum[s] << endl;
}
}
return 0;
}
个人感觉很难的一道乙级题目,反正我是没有一点思路,用了很烦的方法,最后写不下去了看了书上的解法,自己写了一遍。