题目链接
- 简单的数字进制转换,比如13这个数字,应该是两位的但是这个火星语不包括后面的那个零,就变成了只有一位的数。
using namespace std;
int main() {
map<string, int>marToEarthHigh={ {"tam",1}, {"hel",2},{"maa",3},{"huh",4},{"tou",5},{"kes",6},{"hei",7},{"elo",8},{"syy",9},{"lok",10},{"mer",11},{"jou",12} };
map<string, int>marToEarthLow={ {"tret",0},{"jan",1},{"feb",2},{"mar",3},{"apr",4},{"may",5},{"jun",6},{"jly",7},{"aug",8},{"sep",9},{"oct",10},{"nov",11},{"dec",12} };
vector<string> earthToMarHigh = {"###" ,"tam","hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou" };
vector<string> earthToMarLow = { "tret","jan","feb" ,"mar" ,"apr" ,"may" ,"jun" ,"jly" ,"aug" ,"sep" ,"oct" ,"nov" ,"dec" };
string s;
int n;
int res = 0;
cin >> n;
getchar();
while (n--) {
getline(cin, s);
res = 0;
//火星转地球的情况
if (isalpha(s[0])) {
if (s.size() > 5) {
res = marToEarthHigh[s.substr(0, 3)] * 13;
res += marToEarthLow[s.substr(4, s.size() - 4)];
}
else {
if (marToEarthLow.find(s) == marToEarthLow.end()) {//数字在高位中
res = marToEarthHigh[s] * 13;
}
else {
res = marToEarthLow[s];
}
}
cout << res << endl;
}
else {
int num = stoi(s);
int high = num / 13;
int low = num % 13;
if (high != 0)
cout << earthToMarHigh[high];
if (low != 0 && high != 0) {
cout << " ";
}
if (low != 0)
cout << earthToMarLow[low];
if (low == 0 && high == 0)
cout << earthToMarLow[0];
cout << endl;
}
}
}