M01008: Maya Calendar
http://cs101.openjudge.cn/practice/01008/
During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, professor discovered that the Maya civilization used a 365 day long year, called Haab, which had 19 months. Each of the first 18 months was 20 days long, and the names of the months were pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu. Instead of having names, the days of the months were denoted by numbers starting from 0 to 19. The last month of Haab was called uayet and had 5 days denoted by numbers 0, 1, 2, 3, 4. The Maya believed that this month was unlucky, the court of justice was not in session, the trade stopped, people did not even sweep the floor. For religious purposes, the Maya used another calendar in which the year was called Tzolkin (holly year). The year was divided into thirteen periods, each 20 days long. Each day was denoted by a pair consisting of a number and the name of the day. They used 20 names: imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau and 13 numbers; both in cycles. Notice that each day has an unambiguous description. For example, at the beginning of the year the days were described as follows: 1 imix, 2 ik, 3 akbal, 4 kan, 5 chicchan, 6 cimi, 7 manik, 8 lamat, 9 muluk, 10 ok, 11 chuen, 12 eb, 13 ben, 1 ix, 2 mem, 3 cib, 4 caban, 5 eznab, 6 canac, 7 ahau, and again in the next period 8 imix, 9 ik, 10 akbal . . . Years (both Haab and Tzolkin) were denoted by numbers 0, 1, . . . , where the number 0 was the beginning of the world. Thus, the first day was: Haab: 0. pop 0 Tzolkin: 1 imix 0 Help professor M. A. Ya and write a program for him to convert the dates from the Haab calendar to the Tzolkin calendar.
输入
The date in Haab is given in the following format: NumberOfTheDay. Month Year
The first line of the input file contains the number of the input dates in the file. The next n lines contain n dates in the Haab calendar format, each in separate line. The year is smaller then 5000.
输出
The date in Tzolkin should be in the following format: Number NameOfTheDay Year
The first line of the output file contains the number of the output dates. In the next n lines, there are dates in the Tzolkin calendar format, in the order corresponding to the input dates.
样例输入
3
10. zac 0
0. pop 0
10. zac 1995样例输出
3
3 chuen 0
1 imix 0
9 cimi 2801来源: Central Europe 1995
思路:建立两个列表,然后建立二者之间的映射即可。中间一些数学关系容易搞错。
holly year只有年、日。题面挺迷惑。类似天干和地支。
注意到日是从零开始计算的,所以直接用题目的数据就不会出现一年的最后一天要特殊判断。
# 2400010762 焦玮宸 数学科学学院
Haab = {"pop": 0, "no": 1, "zip": 2, "zotz": 3, "tzec": 4, "xul": 5, "yoxkin": 6, "mol": 7, "chen": 8, "yax": 9, "zac": 10, "ceh": 11, "mac": 12, "kankin": 13, "muan": 14, "pax": 15, "koyab": 16, "cumhu": 17, "uayet": 18}
Tzolkin = {0: "imix", 1: "ik", 2: "akbal", 3: "kan", 4: "chicchan", 5: "cimi", 6: "manik", 7: "lamat", 8: "muluk", 9: "ok", 10: "chuen", 11: "eb", 12: "ben", 13: "ix", 14: "mem", 15: "cib", 16: "caban", 17: "eznab", 18: "canac", 19: "ahau"}
n = int(input())
print(n)
for _ in range(n):
day, month, year = input().split()
day = int(day.rstrip("."))
total = int(year) * 365 + Haab[month] * 20 + day
print(total % 13 + 1, Tzolkin[total % 20], total // 260)# 高景行 24-数学科学学院
month1 =\
"pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu".split(", ")
month2 =\
"imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau".split(", ")
chk1 = {}
for i in range(18): chk1[month1[i]] = i
chk1["uayet"] = 18
n = int(input()); print(n)
for i in range(n):
x, y1, y2 = input().split()
day = int(y2) * 365 + chk1[y1] * 20 + int(x.rstrip('.'))
print("{} {} {}".format(day % 13 + 1, month2[day % 20], day // 260))# 2300011760(喜看稻菽千重浪)
A = ['pop', 'no', 'zip', 'zotz', 'tzec', 'xul', 'yoxkin', 'mol', 'chen', 'yax',
'zac', 'ceh', 'mac', 'kankin', 'muan', 'pax', 'koyab', 'cumhu', 'uayet']
B = ['imix', 'ik', 'akbal', 'kan', 'chicchan', 'cimi', 'manik', 'lamat', 'muluk',
'ok', 'chuen', 'eb', 'ben', 'ix', 'mem', 'cib', 'caban', 'eznab', 'canac', 'ahau']
C = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13']
D = {}
for i in range(260):
D[i] = C[i % 13-1]+' '+B[i % 20-1]
n = int(input())
print(n)
for _ in range(n):
a, b, c = input().split()
a = int(a[:-1])
c = int(c)
n = 365*c+A.index(b)*20+a+1
print(D[n % 260]+' '+str((n-1)//260))# 23n2300012115(zinctim)
Haab_month = ['pop','no','zip','zotz','tzec','xul',
'yoxkin','mol','chen','yax','zac','ceh',
'mac','kankin','muan','pax','koyab','cumhu','uayet']
Tzolkin_month = ['imix','ik','akbal','kan','chicchan','cimi','manik',
'lamat','muluk','ok','chuen','eb','ben','ix',
'mem','cib','caban','eznab','canac','ahau']
def trans(d,m,y):
global Haab_month,Tzolkin_month
d = int(d);y = int(y)
days = Haab_month.index(m)*20 + (d+1) + y*365
new_month = str(Tzolkin_month[(days%260)%20-1])
if (days%260)%13==0:
new_date = '13'
else:
new_date = str((days%260)%13)
if days%260 == 0:
new_year = str(days//260-1)
else:
new_year = str(days//260)
return new_date +' '+ new_month +' '+ new_year
l=[]
n = int(input())
for i in range(n):
date , month , year = [str(x).rstrip('.') for x in input().split()]
l.append(trans(date,month,year))
print(n)
for k in l:
print(k)