1100 Mars Numbers (20 分)
 

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:

  1. 4
  2. 29
  3. 5
  4. elo nov
  5. tam

Sample Output:

  1. hel mar
  2. may
  3. 115
  4. 13
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. map<string,int>mp1;
  4. map<string,int>mp2;
  5. string s;
  6. int l;
  7. //mo 为余数,mar 为商
  8. string mo[]={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
  9. string mar[]={"","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
  10. void init()
  11. {
  12. for(int i =;i<=;i++){
  13. mp1[mar[i]] = i;
  14. }
  15. for(int i =;i<=;i++){
  16. mp2[mo[i]] = i;
  17. }
  18. }
  19. void zifu(string s)
  20. {
  21. int ans = ;
  22. for(int i =;s[i];i++){
  23. ans =ans*+s[i]-'';
  24. }
  25. int x=ans/;int y= ans%;
  26. if(x==){
  27. cout<<mo[y]<<endl;
  28. }
  29. else{
  30. if(y==){
  31. cout<<mar[x]<<endl;//如 : 13 :tam 后面没有tret
  32. }
  33. else{
  34. cout<<mar[x]<<" "<<mo[y]<<endl;
  35. }
  36. }
  37. }
  38. void isnum(string s){
  39. string s1,s2;
  40. int p=,q=;
  41. if(l<=){//可能地球文字也可能火星文字
  42. p=mp1[s];
  43. q=mp2[s];
  44. }
  45. else{
  46. s1 =s.substr(,);//从0开始数3个
  47. s2 =s.substr(,);
  48. p =mp1[s1];
  49. q =mp2[s2];
  50. }
  51. printf("%d\n",p*+q);
  52. }
  53. int main()
  54. {
  55.  
  56. int n;
  57. scanf("%d",&n);
  58. getchar();
  59. while(n--){
  60. init();
  61. getline(cin,s);
  62. l =s.length();
  63. if(isdigit(s[])){
  64. zifu(s);
  65. }
  66. else{
  67. isnum(s);
  68. }
  69. }
  70. return ;
  71. }

pat 1100的更多相关文章

  1. PAT 1100 Mars Numbers[难]

    1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called &q ...

  2. pat 1100 Mars Numbers(20 分)

    1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...

  3. PAT 1100. Mars Numbers

    People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. T ...

  4. PAT甲级——1100 Mars Numbers (字符串操作、进制转换)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...

  5. 1100 Mars Numbers——PAT甲级真题

    1100 Mars Numbers People on Mars count their numbers with base 13: Zero on Earth is called "tre ...

  6. PAT (Advanced Level) 1100. Mars Numbers (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  7. PAT甲级题解-1100. Mars Numbers (20)-字符串处理

    没什么好说的,注意字符串的处理,以及当数字是13的倍数时,只需高位叫法的单词.比如26,是“hel”,而不是“hel tret”. 代码: #include <iostream> #inc ...

  8. 【PAT甲级】1100 Mars Numbers (20 分)

    题意: 输入一个正整数N(<100),接着输入N组数据每组包括一行字符串,将其翻译为另一个星球的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESP ...

  9. PAT甲级1100——1155题总结

随机推荐

  1. flutter中的异步机制Future

    饿补一下Flutter中Http请求的异步操作. Dart是一个单线程语言,可以理解成物理线路中的串联,当其遇到有延迟的运算(比如IO操作.延时执行)时,线程中按顺序执行的运算就会阻塞,用户就会感觉到 ...

  2. luogu_3645: 雅加达的摩天楼

    雅加达的摩天楼 题意描述: 有\(N\)座摩天楼,从左到右依次编号为\(0\)到\(N-1\). 有\(M\)个信息传递员,编号依次为\(0\)到\(M-1\).编号为i的传递员最初在编号为\(B_i ...

  3. 小功能 清单模板导入 根据Excel生成树

    把代码备份一下,免得硬盘又坏了,看来已经造成心理阴影了啊. 方式一: //清单范本 public void test1() { //生成说明 var ds = ExcelHelper.ExcelToD ...

  4. [Java] Spring boot 的 SrpingSecurity 框架搭建

    参考: SrpingSecurity]之一:框架搭建https://blog.csdn.net/qq_28296925/article/details/82021092 [SpringSecurity ...

  5. 鸿蒙OS与手机系统

    鸿蒙发布会上,华为只是说手机端能很快切换到鸿蒙上,但并没有将切换到手机端放到计划表.如果不出意外,手机会是最后用上鸿蒙的终端,尽管它是现在对人们最重要.应用最多.也是人们讨论最多希望鸿蒙迁移到的终端. ...

  6. CCF 201909-5 城市规划

    试题编号: 201909-5 试题名称: 城市规划 时间限制: 3.0s 内存限制: 512.0MB 问题描述: 几乎是Gym102222G的原版,详解见上一篇博文 /* 贡献+树形dp+01背包 * ...

  7. cogs 2569. [東方] 博丽灵梦 梦想妙珠

    二次联通门 : cogs 2569. [東方] 博丽灵梦 梦想妙珠 /* cogs 2569. [東方] 博丽灵梦 梦想妙珠 莫队水过.. 好久没一遍AC了.. 卡线上榜2333 */ #includ ...

  8. K8s Service原理介绍

    Service的工作方式有三种: 第一种: 是Userspace方式 如下图描述, Client Pod要访问Server Pod时,它先将请求发给本机内核空间中的service规则,由它再将请求, ...

  9. vue中使用时间插件、vue使用laydate

    <input id="time1" readonly="readonly" placeholder="这里选择时间" v-model= ...

  10. centOS7开启ssh免密登陆

    一.登陆服务器生成ssh-key 二.把ssh-key复制到被登陆机器上 三.设置权限 root# .ssh 文件夹权限 root# .ssh/authorized_keys 文件权限 四.测试是否正 ...