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 ;
}

PAT甲级——A1100 Mars Numbers的更多相关文章

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

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

  2. A1100. Mars Numbers

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

  3. PAT甲级 1120. Friend Numbers (20)

    1120. Friend Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Two in ...

  4. PAT甲级——A1120 Friend Numbers【20】

    Two integers are called "friend numbers" if they share the same sum of their digits, and t ...

  5. A1100 Mars Numbers (20 分)

    一.技术总结 这一题可以使用map进行想打印存储,因为数据量不是很大,最后直接输出.但是还是觉得没有必要. 主要考虑两个问题,首先是数字转化为字符串,实质就是进制转化,但是有点不同,如果十位有数字,个 ...

  6. PAT_A1100#Mars Numbers

    Source: PAT A1100 Mars Numbers (20 分) Description: People on Mars count their numbers with base 13: ...

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

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

  8. PAT 1100 Mars Numbers[难]

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

  9. pat 1100 Mars Numbers(20 分)

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

随机推荐

  1. Apache Spark 2.2.0 中文文档 - Spark SQL, DataFrames and Datasets

    Spark SQL, DataFrames and Datasets Guide Overview SQL Datasets and DataFrames 开始入门 起始点: SparkSession ...

  2. 客户端IAP二次验证

    1.首先苹果IAP把每次购买抽象成了一个事务(SKPaymentTransaction), - (void)productsRequest:(SKProductsRequest *)request d ...

  3. Java 仓储模式

    使用的Spring boot +Jpa 项目层级: common里包含了model,以及一些viewModel等等 下面就是设计的仓储模式 先看下SysUser: @MappedSuperclass ...

  4. innodb_file_per_table 理解

    MYSQL innodb存储引擎 默认将所有的数据库 innodb 引擎的表数据存储在一个共享空间中:ibdata1,当增删数据库的时候, ibdata1文件不会自动收缩,单个数据库的备份也会成为问题 ...

  5. Android开发 AndroidStudio解决Error:moudle not specified

    问题描述 在使用Android Studio 进行Builder APKs的时候,如果发现无法degub, 进行配置的时候 没有module可以进行指定 问题原因 项目未与Grade Files 文件 ...

  6. 学习修复Laravel The only supported ciphers are AES-128-CBC and AES-256-CBC

    The only supported ciphers are AES-128-CBC and AES-256-CBC 在项目中,删除了 .env的APP_KEY的值,再运行 php artisan k ...

  7. C++相对路径和绝对路径

    学习备忘 转自:http://www.cnblogs.com/vranger/p/3820783.html 电脑硬盘E盘下,建文件夹“test”,"test"下建立子文件夹“fil ...

  8. Spring知识点整理

    1.bean什么时候被实例化 第一:如果你使用BeanFactory作为Spring Bean的工厂类,则所有的bean都是在第一次使用该Bean的时候实例化第二:如果你使用ApplicationCo ...

  9. leetcode-240-搜索二维矩阵②

    题目描述: 最佳方法:O(m+n) O(1) class Solution: def searchMatrix(self, matrix, target): if not matrix : retur ...

  10. vue中axios使用封装

    一.在main.js导入 // 引入axios,并加到原型链中 import axios from 'axios'; Vue.prototype.$axios = axios; import QS f ...