Maya Calendar
InterviewTime limit1sMemory limit128 MB
Convert n dates from the Haab calendar to the Tzolkin calendar using modular arithmetic on the day index.
- Level
Medium4 of 10
- Topics
- Math, Implementation, Simulation, Number theory
- Solved
- No attempts yet
Problem
Professor M. A. Ya has been studying the ancient Maya calendars and needs a program to convert dates from one of them to the other.
The Haab calendar has a 365-day year divided into 19 months. Each of the first 18 months has 20 days, and the days are numbered from 0 to 19. The names of these 18 months, in order, are:
pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu
The 19th and last month is called uayet and has only 5 days, numbered 0 to 4, so a year has days. The Maya considered this month unlucky.
The Tzolkin calendar (the holy year) has a 260-day year. Each day is described by a pair: a number together with a day name. There are 20 day names, used in a cycle:
imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau
together with the 13 numbers through , also used in a cycle. The number and the name advance together by one each day, so every day has an unambiguous description. For example, the first days of a Tzolkin year are:
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, 8 imix, 9 ik, 10 akbal, ...
Years in both calendars are numbered , where year marks the beginning of the world. The very first day is therefore:
- Haab:
0. pop 0 - Tzolkin:
1 imix 0
Given dates in the Haab calendar, convert each one to the corresponding Tzolkin date.
Input
Each Haab date is written in the format:
NumberOfTheDay. Month Year
The first line of input contains the number of dates . Each of the next lines contains one date in Haab format. Every year is smaller than .
Output
For each input date, output the corresponding Tzolkin date in the format:
Number NameOfTheDay Year
The first line of output is the number of dates . The next lines contain the converted Tzolkin dates, in the same order as the input.