pat 1100
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的更多相关文章
- PAT 1100 Mars Numbers[难]
1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called &q ...
- pat 1100 Mars Numbers(20 分)
1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...
- PAT 1100. Mars Numbers
People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. T ...
- PAT甲级——1100 Mars Numbers (字符串操作、进制转换)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...
- 1100 Mars Numbers——PAT甲级真题
1100 Mars Numbers People on Mars count their numbers with base 13: Zero on Earth is called "tre ...
- PAT (Advanced Level) 1100. Mars Numbers (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT甲级题解-1100. Mars Numbers (20)-字符串处理
没什么好说的,注意字符串的处理,以及当数字是13的倍数时,只需高位叫法的单词.比如26,是“hel”,而不是“hel tret”. 代码: #include <iostream> #inc ...
- 【PAT甲级】1100 Mars Numbers (20 分)
题意: 输入一个正整数N(<100),接着输入N组数据每组包括一行字符串,将其翻译为另一个星球的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESP ...
- PAT甲级1100——1155题总结
随机推荐
- web前端如何性能优化提高加载速度
前端优化有以下几种途径: 一.减少HTTP请求数量和次数: 二.使用CDN: 三.添加Expires头: 四.压缩组件: 五.将样式表放在头部: 六.将脚本放在底部: 七.避免CSS表达式: 八.使用 ...
- (16)WiringPi库函数
8.WiringPi库函数 一.wiringPi简介 wiringPi是应用于树莓派平台的GPIO控制库函数,wiringPi中的函数类似于Arduino的wiringPi系统,wiringPi库包含 ...
- (13)使用python+flask实现树莓派的WEB控制
https://blog.csdn.net/qq_34803821/article/details/86240096 如果你想在网页上点击按钮,并且让树莓派接收到响应,并做响应的处理,实现网页上与树莓 ...
- mysql和sqliet连接
Python里Django框架数据库要配置1.setting已经自己配置好2.需要自己连接.找到setting里DATABASES进行连接自己数据库MySQL数据库连接 model里创建数据表就是Dj ...
- dotnetcore docker 简单运行
今天试用了下mac 版本的dotnetcore sdk,发现还是很方便的,同时官方的容器运行方式,相对小了好多 同时使用多阶段构建的方式运行dotnetcore 安装sdk 下载地址: https:/ ...
- 【luoguP4720】【模板】扩展卢卡斯
快速阶乘与(扩展)卢卡斯定理 \(p\)为质数时 考虑 \(n!~mod~p\) 的性质 当\(n>>p\)时,不妨将\(n!\)中的因子\(p\)提出来 \(n!\) 可以写成 \(a* ...
- vs code搭建python和tensorflow环境
anaconda 安装tensorflow-gpu环境见https://www.cnblogs.com/wintersoft/p/11620267.html vscode中设置python虚拟环境Ct ...
- phpstudy(小皮面板)和phpstudy2018 配置php的区别
phpstudy(小皮面板)和phpstudy2018 配置php的区别 一.总结 一句话总结: phpstudy(小皮面板) 和 phpstudy2018 只是引入的php的位置不同,但是核心代码还 ...
- android : 解决android无法使用sun.misc.BASE64Encoder sun.misc.BASE64Decoder 的问题, 无需添加rt.jar
一共包含: BASE64Decoder.java BASE64Encoder.java CEFormatException.java CEStreamExhausted.java CharacterD ...
- sql为什么要用where 1=1?
这个1=1常用于应用程序根据用户选择项的不同拼凑where条件时用的.例如:查询用户的信息,where默认为1=1,这样用户即使不选择任何条件,sql查询也不会出错.如果用户选择了姓名,那么where ...