# 算法学习之路|火星数字

4
29
5
elo nov
tam

hel mar
may
115
13

#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<map>
#include<stdio.h>
using namespace std;

map<string,int> s1,s2;
string s11[13]={"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov","dec"};
string s22[13]={"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
string s111="tret,jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec";
string s222="tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou";
int main(){
s1["jan"]=1;
s1["feb"]=2;
s1["mar"]=3;
s1["apr"]=4;
s1["may"]=5;
s1["jun"]=6;
s1["jly"]=7;
s1["aug"]=8;
s1["sep"]=9;
s1["oct"]=10;
s1["nov"]=11;
s1["dec"]=12;
s2["tam"]=1;
s2["hel"]=2;
s2["maa"]=3;
s2["huh"]=4;
s2["tou"]=5;
s2["kes"]=6;
s2["hei"]=7;
s2["elo"]=8;
s2["syy"]=9;
s2["lok"]=10;
s2["mer"]=11;
s2["jou"]=12;
int n;
cin>>n;
getchar();
string v[100];
for(int i=0;i<n;i++){
getline(cin,v[i]);
}
for(int i=0;i<n;i++){
string buff;
if(v[i].find(" ")!=-1){
istringstream sin(v[i]);
string a,b;
sin>>a>>b;
cout<<s2[a]*13+s1[b]<<endl;
}
else if(v[i][0]>='0'&&v[i][0]<='9'){
istringstream sin(v[i]);
int a;
sin>>a;
int x,y;
if(a>=13&&a<=24){
cout<<s22[a-12]<<endl;
}
else if(a>24){
y=a%13;
x=a/13;
cout<<s22[x]<<" "<<s11[y]<<endl;
}
else if(a<=12){
cout<<s11[a]<<endl;
}
}
else if(v[i].find(" ")==-1){

if(s111.find(v[i])!=-1){
cout<<s111.find(v[i])/5<<endl;
}
else if(s222.find(v[i])!=-1){
cout<<s222.find(v[i])/5+13<<endl;
}
}
}
}

+ 订阅