#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
map<string,int> mp;
char A[20][5]={"tret", "jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
char B[20][5]={"","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
void init()
{
mp["tret"]=0;
mp["jan"]=1;
mp["feb"]=2;
mp["mar"]=3;
mp["apr"]=4;
mp["may"]=5;
mp["jun"]=6;
mp["jly"]=7;
mp["aug"]=8;
mp["sep"]=9;
mp["oct"]=10;
mp["nov"]=11;
mp["dec"]=12;
mp["tam"]=13*1;
mp["hel"]=13*2;
mp["maa"]=13*3;
mp["huh"]=13*4;
mp["tou"]=13*5;
mp["kes"]=13*6;
mp["hei"]=13*7;
mp["elo"]=13*8;
mp["syy"]=13*9;
mp["lok"]=13*10;
mp["mer"]=13*11;
mp["jou"]=13*12;
}
int N;
void to13(string str)
{
string result1="";
string result2="";
int number=0;
for(int i=0;i<str.length();i++)
{
number=number*10+str[i]-'0';
}
if(number==0)printf("%s\n",A[0]);
else
{
int step=0;
while(number>0)
{
int pop=number%13;
number/=13;
if(step==0)
{
if(pop!=0)
{
result1=A[pop];
}
}
else
{
result2=B[pop];
}
step++;
}
if(result2.length()==0)
{
cout<<result1<<endl;
}
else if(result1.length()==0)
{
cout<<result2<<endl;
}
else
{
cout<<result2<<" "<<result1<<endl;
}
}
}
void to10(string str)
{
int k=-1;
string temp1,temp2;
for(int i=0;i<str.length();i++)
{
if(str[i]==' ')
{
k=i;
break;
}
}
if(k!=-1)
{
temp1=str.substr(0,k);
temp2=str.substr(k+1,str.length()-k);
}
else
{
temp1=str;
}
int num1=0,num2=0;
if(mp.find(temp1)!=mp.end())
{
num1=mp[temp1];
}
if(mp.find((temp2))!=mp.end())
{
num2=mp[temp2];
}
cout<<num1+num2<<endl;
}
int main()
{
init();
scanf("%d",&N);
getchar();
string str;
for(int i=0;i<N;i++)
{
getline(cin,str);
if(str[0]>='0'&&str[0]<='9')
{
to13(str);
}
else
{
to10(str);
}
}
return 0;
}
PAT甲1100 Mars Numbers(20 分)
最新推荐文章于 2021-02-28 16:14:56 发布