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. BigDecimal保留小数

    public class test1_format { public static void main(String[] args) { BigDecimal decimal = new BigDec ...

  2. Mobius

    Mobius 形式一 \[ f\left(n\right) = \sum_{d|n}g\left(d\right) \\ g\left(n\right) = \sum_{d|n}\mu\left(d\ ...

  3. LeetCode 734. Sentence Similarity

    原题链接在这里:https://leetcode.com/problems/sentence-similarity/ 题目: Given two sentences words1, words2 (e ...

  4. 洛谷 P1731 [NOI1999]生日蛋糕 题解

    每日一题 day53 打卡 Analysis 观察一个蛋糕的俯视图,上表面的面积其实就是最下面那一层的底面积,所以在第一次搜索的时候加入这个底面积,之后就只用考虑侧面积就好啦. 就是每次枚举r和h,如 ...

  5. Linux软件安装——软件包分类、RPM包管理

    1.软件包分类: (1)源码包: 优点:开源,即用户可以看到源代码,用户可以修改源代码:可以自由选择所需的功能:软件是编译安装,效率更高. 缺点:需要手动安装,安装慢. (2)二进制包(RPM包.系统 ...

  6. [原创]STAR法则

    [原创]STAR法则 STAR法则是情境(situation).任务(task).行动(action).结果(result)四项的缩写. STAR法则是一种常常被面试官使用的工具,用来收集面试者与工作 ...

  7. DNS基本操作详解

    在很多人看来,DNS只是为外部提供DNS解析服务(我以前也是这么认为的,直到膝盖中了一箭),但作为互联网的基础设施,DNS远没有想象的那么简单.如果你没有听说过DNS查询.反向解析.zone传输.动态 ...

  8. 对回溯算法的理解(以数独游戏为例,使用c++实现)

    算法思想: 数独游戏的规则: 每一行都用到1.2.3.4.5.6.7.8.9位置不限: 每一列都用到1.2.3.4.5.6.7.8.9位置不限: 每3×3的格子(共九个这样的格子)都用到1.2.3.4 ...

  9. Python快速入门教程【转】

    第一章 Python基础知识 1.1 介绍      1.1.1 特点      Python是一种面向对象.解释型计算机程序设计语言.语法简洁清晰,强制用空白符作为语句缩进.      Python ...

  10. OSS利用ossutil64上传文件

     ossutil64下载地址: http://gosspublic.alicdn.com/ossutil/1.6.0/ossutil64?spm=a2c4g.11186623.2.12.3638159 ...