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:

4
29
5
elo nov
tam

Sample Output:

hel mar
may
115
13
 #include <bits/stdc++.h>
using namespace std;
map<string,int>mp1;
map<string,int>mp2;
string s;
int l;
//mo 为余数,mar 为商
string mo[]={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
string mar[]={"","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
void init()
{
for(int i =;i<=;i++){
mp1[mar[i]] = i;
}
for(int i =;i<=;i++){
mp2[mo[i]] = i;
}
}
void zifu(string s)
{
int ans = ;
for(int i =;s[i];i++){
ans =ans*+s[i]-'';
}
int x=ans/;int y= ans%;
if(x==){
cout<<mo[y]<<endl;
}
else{
if(y==){
cout<<mar[x]<<endl;//如 : 13 :tam 后面没有tret
}
else{
cout<<mar[x]<<" "<<mo[y]<<endl;
}
}
}
void isnum(string s){
string s1,s2;
int p=,q=;
if(l<=){//可能地球文字也可能火星文字
p=mp1[s];
q=mp2[s];
}
else{
s1 =s.substr(,);//从0开始数3个
s2 =s.substr(,);
p =mp1[s1];
q =mp2[s2];
}
printf("%d\n",p*+q);
}
int main()
{ int n;
scanf("%d",&n);
getchar();
while(n--){
init();
getline(cin,s);
l =s.length();
if(isdigit(s[])){
zifu(s);
}
else{
isnum(s);
}
}
return ;
}

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. 使用apache 的FileUtils处理文件的复制等操作

    今日思语:春风很柔,夏风很烈,秋风清爽,东风凛冽,愿你就是春夏秋冬的风~ 平时对一些文件进行操作,比如说写文件,读文件,复制一个文件等,使用原生File操作需要读取源文件,生成流对象,再写入一个新的文 ...

  2. reids 数据库学习

    最近项目中用到了redis数据库,学习整理下 redis操作学习手册--key操作命令 http://www.cnblogs.com/stephen-liu74/archive/2012/03/26/ ...

  3. 爬虫高性能asyncio+ahttpio

    async实现协程,异步编程 我们都知道,现在的服务器开发对于IO调度的优先级控制权已经不再依靠系统,都希望采用协程的方式实现高效的并发任务,如js.lua等在异步协程方面都做的很强大. python ...

  4. pg_flame postgresql EXPLAIN ANALYZE 火焰图工具

    pg_flame 是golang 编写的一个将pg的EXPLAIN ANALYZE 转换为火焰图,使用简单 以下是一个简单的demo 环境准备 docker-compose 文件   version: ...

  5. 7.学习springmvc的异常处理

    一.页面的异常处理流程 二.建立项目springmvc04_exception 1.编写index.jsp页面: <%@ page contentType="text/html;cha ...

  6. springboot与ssm的差异性

    springboot简化了ssm的配置 将外部jar包改为内部pom.xml文件配置 同时 使用了多种注解来进行注解式的开发 [图1:springboot的一些依赖模块] 通过原springmvc机制 ...

  7. 【luoguP5490】【模板】扫描线

    求\(n\)个矩形的面积并,可以用线段树维护一条垂直于\(y\)轴的直线上被矩形覆盖的长度有多少长,将直线从左往右扫一遍,遇到矩形左边界就+1,遇到右边界就-1,不为\(0\)的位置就表示没有覆盖 不 ...

  8. Hash总结

    算法介绍 这个没什么好说的,就是一段比较简单的代码,具体的话要看题目. 自然溢出 这个是比较好用而且容易被卡的一种Hash方式. 用\(2^{64}\)当模数然后做\(Hash\),常数比较小. 单模 ...

  9. Spring的注解收集

    @Scope("prototype")spring 默认scope 是单例模式scope="prototype" 可以保证 当有请求的时候 都创建一个Actio ...

  10. Metasploit使用内网跳板, 扫描局域网主机

    最近,拿到一台内网机器, 苦于无法使用nmap扫描改主机的内网, 所以才有此文 在跳板机子获取一定权限后,需要积极的向内网主机权限发展,获取指定的目标信息,探查系统漏洞,借助msf已经得到的meter ...