pat 1100 Mars Numbers(20 分)
Posted getcharzp
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pat 1100 Mars Numbers(20 分)相关的知识,希望对你有一定的参考价值。
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 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
1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #include <cstring> 5 #include <string> 6 #include <map> 7 #include <stack> 8 #include <vector> 9 #include <queue> 10 #include <set> 11 #define LL long long 12 #define INF 0x3f3f3f3f 13 using namespace std; 14 const int MAX = 30; 15 16 int n; 17 string s; 18 char s1[MAX][6] = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"}; 19 char s2[MAX][6] = {" ", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"}; 20 21 int my_pow(int x, int n) 22 { 23 int ans = 1; 24 while (n) 25 { 26 if (n & 1) ans *= x; 27 x *= x; 28 n >>= 1; 29 } 30 return ans; 31 } 32 33 int main() 34 { 35 // freopen("Date1.txt", "r", stdin); 36 scanf("%d", &n); 37 getchar(); 38 for (int i = 1; i <= n; ++ i) 39 { 40 getline(cin, s); 41 if (isalpha(s[0])) 42 { 43 int len = s.size(); 44 if (len >= 6) 45 { 46 char str1[6], str2[6]; 47 int a = 0, b = 0, ans = 0; 48 for (a, b; a < len; ++ a, ++ b) 49 { 50 if (s[a] == ‘ ‘) break; 51 str1[b] = s[a]; 52 } 53 str1[b] = ‘