#include <iostream>
#include <unordered_map>
#include <sstream>
#include <string>
using namespace std;
unordered_map<string,int> decStringToInt;
unordered_map<int,string> decIntToString;
unordered_map<string,int> unitStringToInt;
unordered_map<int,string> unitIntToString;
void init(){
unitStringToInt["jan"] = 1,unitStringToInt["feb"] = 2,unitStringToInt["mar"] = 3,unitStringToInt["apr"] = 4;
unitStringToInt["may"] = 5,unitStringToInt["jun"] = 6,unitStringToInt["jly"] = 7,unitStringToInt["aug"] = 8;
unitStringToInt["sep"] = 9,unitStringToInt["oct"] = 10,unitStringToInt["nov"] = 11,unitStringToInt["dec"] = 12;
unitIntToString[1] = "jan",unitIntToString[2] = "feb",unitIntToString[3] = "mar",unitIntToString[4] = "apr";
unitIntToString[5] = "may",unitIntToString[6] = "jun",unitIntToString[7] = "jly",unitIntToString[8] = "aug";
unitIntToString[9] = "sep",unitIntToString[10] = "oct",unitIntToString[11] = "nov",unitIntToString[12] = "dec";
decStringToInt["tam"] = 1,decStringToInt["hel"] = 2,decStringToInt["maa"] = 3,decStringToInt["huh"] = 4;
decStringToInt["tou"] = 5,decStringToInt["kes"] = 6,decStringToInt["hei"] = 7,decStringToInt["elo"] = 8;
decStringToInt["syy"] = 9,decStringToInt["lok"] = 10,decStringToInt["mer"] = 11,decStringToInt["jou"] = 12;
decIntToString[1] = "tam",decIntToString[2] = "hel",decIntToString[3] = "maa",decIntToString[4] = "huh";
decIntToString[5] = "tou",decIntToString[6] = "kes",decIntToString[7] = "hei",decIntToString[8] = "elo";
decIntToString[9] = "syy",decIntToString[10] = "lok",decIntToString[11] = "mer",decIntToString[12] = "jou";
}
int main(){
int n;
scanf("%d",&n);
cin.get();
init();
for(int i = 0;i < n;i++){
string num;
getline(cin,num);
if(num[0] <= '9' && num[0] >= '0'){ // Earth Numbers
stringstream ss;
ss<<num;
int k;
ss>>k;
int tenth = k / 13;
int deci = k % 13;
if(tenth == 0 && deci != 0){
printf("%s",unitIntToString[deci].c_str());
}else if(tenth == 0 && deci == 0){
printf("tret");
}else if(tenth != 0 && deci == 0){
printf("%s",decIntToString[tenth].c_str());
}else if(tenth != 0 && deci != 0){
printf("%s %s",decIntToString[tenth].c_str(),unitIntToString[deci].c_str());
}
}else{ // Mars Numbers
if(num == "tret")
printf("0");
else{
if(num.length() > 3){ // 有十位也有个位
string tenth,unit;
for(int i = 0;i < 3;i++){
tenth = tenth + num[i];
}
for(int i = 4;i < 7;i++){
unit = unit + num[i];
}
int res = decStringToInt[tenth] * 13 + unitStringToInt[unit];
printf("%d",res);
}else{ // 只有十位或只有个位
int res;
if(decStringToInt.find(num) != decStringToInt.end()){ //只有十位
res = decStringToInt[num] * 13;
printf("%d",res);
}else{
printf("%d",unitStringToInt[num]);
}
}
}
}
if(i != n - 1)
printf("\n");
}
system("pause");
return 0;
}
PAT | A1100 Mars Numbers
最新推荐文章于 2024-08-13 15:05:22 发布