本文主要是介绍1100 Mars Numbers (20 分)(使用python),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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 (<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
a=int(input())
p1=["tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"]
p2=["tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"]
list1=[]
sum1=0
for i in range(a):list1.append(input())
for i in range(len(list1)):if list1[i].isdigit()==True:if int(list1[i])<13:b=int(list1[i])print(p1[b])elif int(list1[i])>=13 and int(list1[i])<169:b=int(list1[i])b1=int(b/13)b2=b%13if b2!=0:print("%s %s"%(p2[b1-1],p1[b2]))elif b2==0:print("%s"%p2[b1-1])else:if len(list1[i])==3:for g in range(13):if p1[g]==list1[i][:3]:print(g)breakfor g2 in range(12):if p2[g2]==list1[i][:3]:print((g2+1)*13)breakif len(list1[i])==7:sum1=0for g1 in range(12):if p2[g1]==list1[i][0:3]:sum1=(g1+1)*13breakfor j in range(13):if p1[j]==list1[i][4:7]:sum1=sum1+jbreakprint(sum1)if len(list1[i])==4:print("0")
这篇关于1100 Mars Numbers (20 分)(使用python)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!