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<stdio.h>
#include<string>
#include<iostream>
#include<string.h>
#include<sstream>
#include<vector>
#include<map>
using namespace std;
char firwei[][]={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
char secwei[][]={"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
map<string,int> mm1,mm2;
void toMar(int n)
{
vector<string> vv;
vv.push_back(firwei[n%]);
n = n / ;
if(n > )
{
vv.push_back(secwei[n]);
}
bool fir = ;
for(int i = vv.size() - ; i >= ;--i )
{
if(fir)
{
cout << vv[i];
fir = ;
}
else if( vv [i] != "tret" )cout << " " << vv[i] ;
}
cout << endl;
} int main()
{
int n;
for(int i = ;i < ;++i)
{
mm1[firwei[i]] = i;
}
for(int i = ;i < ;++i)
{
mm2[secwei[i]] = i;
}
scanf("%d",&n);
getchar();
string str;
for(int i = ;i < n;++i)
{
getline(cin,str);
if(str[]>='' && str[] <= '')
{
int num;
stringstream ss;
ss << str;
ss >> num;
toMar(num);
}
else
{
stringstream ss;
vector<string> svv;
string num;
int sum = ;
ss << str;
while(ss >> num)
{
svv.push_back(num);
}
if(svv.size() > )
{
sum = sum* + mm2[svv[]];
sum = sum* + mm1[svv[]];
}
else
{
sum = sum* + mm2[svv[]];
sum = sum* + mm1[svv[]];
}
printf("%d\n",sum);
}
}
return ;
}

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

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

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

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

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

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

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

  4. pat1100. Mars Numbers (20)

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

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

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

  6. pat 1100 Mars Numbers(20 分)

    1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...

  7. PAT 1100 Mars Numbers[难]

    1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called &q ...

  8. 1100 Mars Numbers——PAT甲级真题

    1100 Mars Numbers People on Mars count their numbers with base 13: Zero on Earth is called "tre ...

  9. 1100 Mars Numbers(20 分)

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

随机推荐

  1. Android必会小功能总结

    1.获取屏幕尺寸.密度等信息. 1)最常用的方法: WindowManager windowManager = getWindowManager(); Display display = window ...

  2. ios菜鸟总结2

    这个星期学起oc来可能是最纠结的.话不多说先补充一下上一个星期的快捷键吧.工程导航器:Command+1    显示/隐藏导航器面板:Command+0 .显示/隐藏实用工具面板:Command+Op ...

  3. struts1.3设置编码三种方法

    本文所写涉及的struts的版本是1.3x. 一.改写struts的ActionServlet. 重写process()方法: 配置相应的web.xml文件   三.通过Chain来处理: 使用cha ...

  4. Unrecognized VM 'MaxMetaspaceSize

    这个错误是因为 MaxMetaspace  元空间是java8的新参数,如所以java8以下的版本,jvm是不支持这个参数的.

  5. 开篇,UVA 755 && POJ 1002 487--3279 (Trie + DFS / sort)

    博客第一篇写在11月1号,果然die die die die die alone~ 一道不太难的题,白书里被放到排序这一节,半年前用快排A过一次,但是现在做的时候发现可以用字典树加深搜,于是乐呵呵的开 ...

  6. 数理方程:Fourier级数

    更新:25 MAR 2016 对于周期函数(周期为\(2\pi\))或定义在\([-\pi,\pi]\)上的函数\(f(x)\),可以展开为* \(\large f(x)=\dfrac{a_0}{2} ...

  7. django 学习-15 .Django文件上传(用户注册)

    1.vim blog/views.py from django.shortcuts  import  render_to_responsefrom django.http   import HttpR ...

  8. ORACLE的分组统计之CUBE(二)

    cube统计包含了rollup的统计结果,而且还有其他组合分组结果(小计),CUBE(n列),那么分组种类有: cube分组就是先进行合计(一个不取),然后小计(到),最后取标准分组. 与rollup ...

  9. 北大ACM(POJ1013-Counterfeit Dollar)

    Question:http://poj.org/problem?id=1013 问题点:排除+验证. Memory: 244K Time: 16MS Language: C++ Result: Acc ...

  10. VxWorks 6.9 内核编程指导之读书笔记 -- 多任务

    概述 VxWork系统任务 任务调度 任务创建和管理 任务的错误状态 任务异常处理 共享代码和重入 概述 现代实时操作系统是基于多任务和任务间通信的概念的.多任务环境运行一个实时进程RTP可以被作为一 ...