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. Codeforces Round #603 (Div. 2) D. Secret Passwords(并查集)

    链接: https://codeforces.com/contest/1263/problem/D 题意: One unknown hacker wants to get the admin's pa ...

  2. 重温Elasticsearch

    什么是 Elasticsearch ? Elasticsearch (ES) 是一个基于 Lucene 构建的开源.分布式.RESTful 接口全文搜索引擎.还是一个分布式文档数据库,其中每个字段均是 ...

  3. 浏览器正在等待locatehost的响应

    1.问题描述 在进行了几次增删改查操作后,浏览器显示浏览器正在等待locatehost的响应: 2.错误原因: 对数据库为关闭相应的资源. 3.解决方案: 关闭JDBC开启的资源:

  4. E. Antenna Coverage (dp)

    传送门 题意: 在一个一维坐标上,有 n 个东西, 每个东西, 用 xi, si 表示 这个东西在 xi 位置上, 它能覆盖到的区间为 [ xi - si, xi + si ]: 然后, 你可以对任意 ...

  5. 12-网页,网站,微信公众号基础入门(编写后台PHP程序,实现Airkiss配网)

    https://www.cnblogs.com/yangfengwu/p/11067590.html 首先说一下,这两个地方需要配置一样 网站根目录建个文件夹 airkiss的文件夹 里面放上 ind ...

  6. 统计学基础知识(一)---描述统计学(Descriptive Statistics)

    描述统计学(Descriptive Statistics):将数据的信息以表格, 图形或数值的形式进行汇总. 数据类型:分为定量数据(数值型数据)和定性数据(类别型数据).数值型数据又可以分为连续型和 ...

  7. 【MonkeyRunner】[技术博客]用python编写脚本查看设备信息

    [MonkeyRunner]用python编写脚本查看设备信息 原以为是个简单的操作,在实践的时候发现了一些问题. python脚本 test.py: from com.android.monkeyr ...

  8. JAVA字符编码二:Unicode,ISO-8859,GBK,UTF-8编码及相互转换

    第二篇:JAVA字符编码系列二:Unicode,ISO-8859-1,GBK,UTF-8编码及相互转换   1.函数介绍 在Java中,字符串用统一的Unicode编码,每个字符占用两个字节,与编码有 ...

  9. Java finally未被执行的情况

    一种是先执行了用于终止程序的System.exit()方法,或进程被关闭 还有一种情况是,当前线程一直在执行,在一些业务逻辑里面跳不出来,看上去就像finally一直未被执行 线程被终止的时候也会执行 ...

  10. android测试和iOS测试的区别

    一.常识性区别 二.导航方式 iOS:Tab放在页面底部,不能通过滑动来切换,只能点击.也有放在上面的,也不能滑动,但有些Tab本身可以滑动,比如天猫的.还有新闻类的应用. Android:一般放在页 ...