1100 Mars Numbers

#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int getnum(string temp){
	int ans=0;
	for(int i=0;i<temp.size();i++){
		ans=ans+(temp[i]-'0')*pow(10,temp.size()-i-1);
	}
	return ans;
}
string hash1[13]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
string hash2[12]={"tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	#endif 
	int n;
	cin>>n;
	getchar();
	for(int i=0;i<n;i++){
		string temp;
		getline(cin,temp);
		if(temp.size()==4) cout<<0<<endl;
		else if(temp.size()>4){
			string temp1,temp2;
			temp1=temp.substr(0,3);
			temp2=temp.substr(4,3);
			int ans=0;
			for(int i=0;i<12;i++){
				if(hash2[i]==temp1){
					ans=ans+(i+1)*13;break;
				}
			}
			for(int i=1;i<13;i++){
				if(hash1[i]==temp2){
					ans=ans+i;break;
				}
			}
			cout<<ans<<endl;
		}else if(temp.size()<4){
			if(temp[0]<='9'&&temp[0]>='0'){
				int t=getnum(temp);
				if(t<=12){
					cout<<hash1[t]<<endl;
				}else if(t>12&&t<169){
					if(t%13!=0)
					cout<<hash2[t/13-1]<<' '<<hash1[t%13]<<endl;
					else cout<<hash2[t/13-1]<<endl;
				}
			}else if(temp[0]>='a'&&temp[0]<='z'){
				for(int i=0;i<13;i++){
					if(hash1[i]==temp){
						cout<<i<<endl;break;
					}
				}
				for(int i=0;i<12;i++){
					if(hash2[i]==temp){
						cout<<(i+1)*13<<endl;break; 
					}
				}
			}
		}
	}
	return 0;
}
 

猜你喜欢

转载自blog.csdn.net/csg3140100993/article/details/81627355