火星数字

#include<bits/stdc++.h>
using namespace std;
string numTostr[170];
map<string,int> strTonum;

string unitDigit[13]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
string tenDigit[13]={"tret","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};

void Init() {
	for(int i=0; i<13;i++) {
		numTostr[i]=unitDigit[i];
		strTonum[unitDigit[i]]=i;
		numTostr[i*13]=tenDigit[i];
		strTonum[tenDigit[i]]=i*13;
	}
	for(int i=1;i<13;i++){
		for(int j=1;j<13;j++){
			string str=tenDigit[i]+" "+unitDigit[j];
			numTostr[i*13+j]=str;
			strTonum[str]=i*13+j;
		}
	}
}

int main() {
	Init();
	int n,x;
	cin>>n;
	cin.ignore();
	string s;
	for(int i=0;i<n;i++){
		getline(cin,s);
		if('0'<=s[0]&&s[0]<='9'){
			x=stoi(s);
			cout<<numTostr[x]<<endl;
		}else{
			cout<<strTonum[s]<<endl;
		}
	}
	return 0;
}

全部评论

相关推荐

去B座二楼砸水泥地:不过也可以理解,这种应该没参加过秋招
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务