1100. Mars Numbers (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

People on Mars count their numbers with base 13:

  • Zero on Earth is called "tret" on Mars.
  • The numbers 1 to 12 on Earch 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 (< 100). 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<cstdio>
#include<cstring>
#include<iostream>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
string dight[][]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec",
"tret","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int n,num;
string s;
scanf("%d",&n);
while(n--){
cin>>s;
int i,j;
num=;
if(s[]>=''&&s[]<=''){
for(i=;i<s.length();i++){
num*=;
num+=s[i]-'';
}
if(num>){
cout<<dight[][num/];
num%=;
if(num){
cout<<" "<<dight[][num];
}
cout<<endl;
}
else{
cout<<dight[][num]<<endl;
}
}
else{
for(i=;i<;i++){
if(dight[][i]==s){
break;
}
}
if(i!=){
num+=*i;
if(getchar()==' '){
cin>>s;
for(i=;i<;i++){
if(dight[][i]==s){
break;
}
}
num+=i;
}
}
else{
for(i=;i<;i++){
if(dight[][i]==s){
break;
}
}
num+=i;
}
printf("%d\n",num);
}
}
return ;
}

pat1100. Mars Numbers (20)的更多相关文章

  1. PAT1100:Mars Numbers

    1100. Mars Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People o ...

  2. 1100. Mars Numbers (20)

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

  3. PAT (Advanced Level) 1100. Mars Numbers (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  4. PAT甲级题解-1100. Mars Numbers (20)-字符串处理

    没什么好说的,注意字符串的处理,以及当数字是13的倍数时,只需高位叫法的单词.比如26,是“hel”,而不是“hel tret”. 代码: #include <iostream> #inc ...

  5. A1100 Mars Numbers (20 分)

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

  6. 【PAT甲级】1100 Mars Numbers (20 分)

    题意: 输入一个正整数N(<100),接着输入N组数据每组包括一行字符串,将其翻译为另一个星球的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESP ...

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

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

  8. PAT_A1100#Mars Numbers

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

  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. springcloud中通过Filter实现微服务跨域访问允许

    import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.an ...

  2. c语言常使用的函数,见到一个记一个

    1.strdup() 功能:克隆一个副本,具有独立的内存空间 声明:char *strdup(char *str): 原型: char * __strdup (const char *s) { siz ...

  3. DropDownList 控件的SelectedIndexChanged事件触发不了

    先看看网友的问题: 根据Asp.NET的机制,在html markup有写DropDownList控件与动态加载的控件有点不一样.如果把DropDownList控件写在html markup,即.as ...

  4. appium报错信息:Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"]”

    appium+Java 自动化测试真机测试时报错“info: [debug] Error: Could not extract PIDs from ps output. PIDS: [], Procs ...

  5. MariaDB之SQL语句基础

    数据库组件: 数据库:database 表: table 索引:index 视图:view 用户:user 权限:privileges 存储过程:procedure 存储函数:function 触发器 ...

  6. UDP socket

    1.Udp :User Datagram Protocol(Udp)用户数据报文协议. 2.适用于局域网的主机间通信. 3.使用方法 1:创建Socket OS_Socket local(127.0. ...

  7. P4015 运输问题

    \(\color{#0066ff}{题目描述}\) W 公司有 m 个仓库和 n 个零售商店.第 i 个仓库有 \(a_i\) 个单位的货物:第 j 个零售商店需要 \(b_j\) 个单位的货物. 货 ...

  8. Educational Codeforces Round 59 (Rated for Div. 2)

    熬夜爆肝,智商急剧下降 坐标UTC+8晚上23:35开始 晚上脑袋转的慢,非常慢 T1上来先做还花了好几分钟 T2本来是有式子的我TM写数位DP写炸了然后才发现是有公式 T3英语不好,一开始题意没读懂 ...

  9. Python学习之路--1.0 Python概述及基本数据类型

    Python是一门解释性语言,弱类型语言 python程序的两种编写方式: 1.进入cmd控制台,输入python进入编辑模式,即可直接编写python程序 2.在.朋友文件中编写python代码,通 ...

  10. vue.js组件之j间的通讯四,通过单一事件来管理组件通讯

    总结; 首先需要创建是一个空实例: var vm = new Vue(); vm.$emit(事件,数据); vm.$on(事件,function(data){ }bind(this))