博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT 1100. Mars Numbers
阅读量:5287 次
发布时间:2019-06-14

本文共 1830 字,大约阅读时间需要 6 分钟。

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
#include
#include
#include
using namespace std;int main(){ vector
gewei{"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"}; vector
shiwei{"#","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"}; int N; cin>>N; string s,str; int a,b,c; getchar(); while(N--){ int sum=0; getline(cin,s); if(isdigit(s[0])){ c=stoi(s); // 将s转化为int if(c<13) cout<
<
>str){ auto it=find(shiwei.begin(),shiwei.end(),str); if(it!=shiwei.end()) sum+=(it-shiwei.begin())*13; auto itt=find(gewei.begin(),gewei.end(),str); if(itt!=gewei.end()) sum+=(itt-gewei.begin()); } cout<
<

转载于:https://www.cnblogs.com/A-Little-Nut/p/8430028.html

你可能感兴趣的文章
ubuntu 常见命令整理
查看>>
EJBCA安装教程+postgresql+wildfly10
查看>>
(五十四)涂鸦的实现和截图的保存
查看>>
配置EditPlus使其可以编译运行java程序
查看>>
java中的占位符\t\n\r\f
查看>>
MySQL通过frm 和 ibd 恢复数据过程
查看>>
SRS源码——Listener
查看>>
Java面向对象抽象类案例分析
查看>>
对SPI、IIC、IIS、UART、CAN、SDIO、GPIO的解释
查看>>
Thymeleaf模板格式化LocalDatetime时间格式
查看>>
庖丁解“学生信息管理系统”
查看>>
Pyltp使用
查看>>
其他ip无法访问Yii的gii,配置ip就可以
查看>>
php做的一个简易爬虫
查看>>
x的x次幂的值为10,求x的近似值
查看>>
jquery获取html元素的绝对位置和相对位置的方法
查看>>
ios中webservice报文的拼接
查看>>
Power BI 报告的评论服务支持移动设备
查看>>
ACdream 1068
查看>>
HDU 2665 Kth number
查看>>