I. TopicsMaya Calendar
Time Limit: 1000MS |
|
Memory Limit: 10000K |
Total Submissions: 74085 |
|
Accepted: 22819 |
Description
During His last sabbatical, Professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, Professor discovered, the Maya civilization used a 365 day long year, called Haab, which Had months. Each of the first months is a 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 have names, the days of the months were denoted by numbers starting from 0 to 19. The last month of Haab is called Uayet and had 5 days denoted by numbers 0, 1, 2, 3, 4. The Maya believed that this month is unlucky, the Court of Justice is not in session, the trade stopped, people do not Even sweep the floor.
For religious purposes, the Maya used another calendar in which the year is called Tzolkin (Holly Year). The year is divided into thirteen periods and each of the days long. Each day is denoted by a pair consisting of a number and the name of the day. They used Names:imix, IK, Akbal, kan, Chicchan, Cimi, Manik, Lamat, Muluk, OK, Chuen, EB, Ben, IX, Mem, CIB, Caban, EZ NAB, Canac, Ahau and numbers; both in cycles.
Notice that all day have 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, ten OK, one Chuen, EB, 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, ten Akbal ...
Years (both Haab and Tzolkin) were denoted by numbers 0, 1,:::, where the number 0 is the beginning of the world. Thus, the first day is:
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.
Input
The date in Haab was 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, and each of the separate line. The year was smaller then 5000.
Output
The date in Tzolkin should is 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 is dates in the Tzolkin calendar format, in the order corresponding to the input dates.
Sample Input
310. Zac 00. Pop 010. Zac 1995
Sample Output
Chuen Imix Cimi 2801
Source
Central Europe 1995
two. Test Instructions
- Maya civilization has two kinds of calendars.
- Haab
- 365 Days a year
- 19 Months:
- First 18 months, 20 days per month, 19th month 5 days
- Representation method: 0. Pop 0
- 0.: One day of the month, counting starting from 0
- Pop: The character representation of the month
- 0: Year, counting starting from 0
- Tzolkin
- 260 Days a year
- 13 Cycles
- 20 days per cycle
- Presentation method: 1 Imix 0
- 1: One day of a cycle, counting starting from 1
- Imix: A character representation of a period
- 0: Year, counting starting from 0
- Give a HAAB expression of a certain day of the year
- The output corresponds to the Tzolkin representation
Three. Analysis
- Algorithm Core: Character processing/congruence problem
- Implementation Details:
- Converts the date represented by Haab to the total number of days from start to current date
- According to the method of Tzolkin representation
- The remainder of the total number of cycles (13)
- Take the remainder of the number of days (20) for each cycle, and use it to obtain its corresponding character representation for the index
- The remainder of the number of days (269) per year
Four. The puzzle
1#include <stdio.h>2 3 #defineH_months 194 #defineH_month_days 205 #defineH_year_days 3656 #defineH_month_len 77 8 #defineT_periods 139 #defineT_cycles 20Ten #defineT_days 260 One A Char* Hms[h_months] = {"Pop","No","Zip","Zotz","Tzec","XUL","Yoxkin", - "Mol","Chen","Yax","Zac","CEH","mac","Kankin", - "Muan","Pax","Koyab","Cumhu","Uayet"}; the - Char* Tds[t_cycles] = {"Imix","ik","Akbal","kan","Chicchan","Cimi","Manik", - "Lamat","Muluk","OK","Chuen","EB","Ben","IX","Mem", - "CIB","Caban","Eznab","Canac","Ahau"}; + - intMYSTRCMP (Const Char*STR1,Const Char*str2) + { A while(*STR1 = = *str2) { at if(*STR1 = =' /')return 0; -str1++; str2++; - } - - return*STR1-*str2; - } in - intShmonth_to_hmonth (Const Char*shmonth) to { + Longi =0; - for(i =0; i < h_months; i++) the if(0= = mystrcmp (Shmonth, hms[i]))returni; * $ returni;Panax Notoginseng } - the intMainvoid) + { A intI, N; the intHday, Hmonth, hyear; + -scanf"%d\n", &N); $printf"%d\n", N); $ - for(i =0; i < N; i++) { - intDays =0; the CharShmonth[h_month_len]; - Wuyiscanf"%d.%s%d\n", &hday, Shmonth, &hyear); theHmonth =Shmonth_to_hmonth (shmonth); - WuDays = hyear * h_year_days + hmonth * h_month_days +Hday; - Aboutprintf"%d%s%d\n", Days% t_periods +1, $Tds[days%T_cycles], -Days/t_days); - } - A return 0; +}
[POJ] #1008 # Maya Calendar: Character processing/congruence issues