People on Mars count their numbers with base 13:

  • Zero on Earth is called "tret" on Mars.
  • The numbers 1 to 12 on Earth is called "jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec" on Mars, respectively.
  • For the next higher digit, Mars people name the 12 numbers as "tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou", respectively.

For examples, the number 29 on Earth is called "hel mar" on Mars; and "elo nov" on Mars corresponds to 115 on Earth. In order to help communication between people from these two planets, you are supposed to write a program for mutual translation between Earth and Mars number systems.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive integer N (<). Then N lines follow, each contains a number in [0, 169), given either in the form of an Earth number, or that of Mars.

Output Specification:

For each number, print in a line the corresponding number in the other language.

Sample Input:

4
29
5
elo nov
tam

Sample Output:

hel mar
may
115
13
 #include<bits/stdc++.h>
using namespace std;
int main(){
string low[]={//数字到火星文低位的映射
"tret","jan","feb","mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
string high[]={//数字到火星文高位的映射
"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
unordered_map<string,int>temp;//火星文到数字的映射
for(int i=;i<;++i){
temp[low[i]]=i;
temp[high[i]]=i*;
}
int n;
scanf("%d%*c",&n);
string digit="";
while(n--){
getline(cin,digit);
if(isdigit(digit[])){//如果是数字
int k=stoi(digit);
if(k/!=)//高位不为0,输出高位
printf("%s",high[k/].c_str());
if(k/!=&&k%!=)//高位低位均不为0,输出空格
printf(" ");
if(k/==||k%!=)//高位为0或者高位不为0但低位为0时,输出低位
printf("%s",low[k%].c_str());
puts("");//换行
}else{//是火星文
int k=;
stringstream stream(digit);
while(stream>>digit)//按空格键分割字符串
k+=temp[digit];
printf("%d\n",k);
}
}
return ;
}

最新文章

  1. docker学习(1) 安装
  2. 2016.8.14安装myplayer心得
  3. 深入研究虚拟机之垃圾收集(GC)算法实现
  4. 你需要管理员权限才能删除文件夹及服务器C盘不及批处理
  5. 大理石在哪?(Where is the Marble?,UVa 10474)
  6. 部署ganglia3.7
  7. C++11之使用或禁用对象的默认函数
  8. OC之Copy语法
  9. Android菜单详解(一)——理解android中的Menu
  10. SqlServer查询数据库所有表
  11. Matrix+POJ+二维树状数组初步
  12. 我的第一个python web开发框架(13)——工具函数包说明(四)
  13. AJAX 笔记
  14. spring 5.1.2 mvc RequestMappingHandlerMapping 源码初始化过程
  15. 洗礼灵魂,修炼python(90)-- 知识拾遗篇 —— 协程
  16. 新萌渗透测试入门DVWA 教程2:DWVA 的配置和暴力破解靶机
  17. Spring MVC基础知识整理➣国际化和异常处理
  18. 学习Mysql过程中拓展的其他技术栈:Docker入门介绍
  19. vue父子组件嵌套的时候遇到 - Component template should contain exactly one root element. If you are using v-i
  20. Swift - 绘制背景线条

热门文章

  1. HTML_标签
  2. Sqlite &amp;&amp; EF Code FIRST 终极解决方案 2019.5.17
  3. double to string 损失精度的问题
  4. OrCAD(2) -- 编辑原理图库时的复制与粘贴
  5. JMeter 返回Json数据提取方法
  6. hdu多校第三场 1006 (hdu6608) Fansblog Miller-Rabin素性检测
  7. vue.js+element ui Table+spring boot增删改查
  8. CSS表格属性
  9. KVM桥接网络
  10. 3列滚动抽奖 jquery.slotmachine