07: The Mayan Calendar

Source: Internet
Author: User

Source: http://noi.openjudge.cn/ch0113/07/

POJ 1008

Total time limit: 1000ms memory limit: 65536kB
Describe

Last weekend, Professor M.A a significant discovery of the ancient Maya. From an ancient knot rope (the Mayan tool for remembering notes), the professor found that the Maya used a calendar of 365 days a year called Haab. This Haab calendar has 19 months, at the beginning of 18 months, one months have 20 days, the name of the month is pop, no, zip, Zotz, Tzec, XUL, Yoxkin, Mol, Chen, Yax, Zac, CEH, Mac, Kankin, Muan , Pax, Koyab, Cumhu. The dates in these months are expressed in 0 to 19. The last one months of the Haab calendar are called Uayet, and it is only 5 days, denoted by 0 to 4. The Maya believed that the least-dated month was unlucky, that the court would not be in session this month, that people were not engaged in trading, and that no one even cleaned the floor of the house.

For religious reasons, the Maya also used another calendar, which was called Tzolkin (Holly years) in this calendar year, which was divided into 13 different periods, each with 20 days each, and each day represented by a combination of numbers and a word. The number used is 1~13, with a total of 20 words, namely: Imix, IK, Akbal, kan, Chicchan, Cimi, Manik, Lamat, Muluk, OK, Chuen, EB, Ben, IX, Mem, CIB, C Aban, Eznab, Canac, Ahau. Note: Each day of the year has a clear and unique description, for example, at the beginning of the year, the date is 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,, 8 Imix, 9 ik, ten Akbal ... This means that the numbers and words are used independently of each other. The years in the

Haab calendar and Tzolkin calendar are numbered 0, 1, ... Indicates that the number 0 represents the beginning of the world. So the first day is expressed as:
haab:0. Pop 0
Tzolkin:1 imix 0
please help M.A. Professor Ya wrote a program to convert the Haab calendar into a Tzolkin calendar.

Input
The
data in the Haab calendar is represented in the following way:
Date. Year of month

The first line in the input represents the amount of data for the Haab calendar date to convert. Each of the following lines represents a date and the number of years is less than 5000.
Output
The
data in the Tzolkin calendar is represented in the following way:
Days number of days name years

The first line represents the number of dates for the output. Each of the following lines represents a date in the corresponding Tzolkin calendar in the input data.
Sample input
310. Zac 00. Pop 010. Zac 1995
Sample output
Chuen Imix Cimi 2801

Thinking Analysis:

1. Convert the entered date to the number of days from the start point of the date
Temp=findhaabmonth (haabmonth);//Returns the ordinal of the month (1~19) based on the name of the month entered
sum=haabyear*365+ (temp-1) *20+haabday+1;
This place temp-1 is to calculate the number of days temp-1 months prior to the first temp month;
Haabday+1 is because the date number entered is starting at 0.
2, then calculate the corresponding Tzolkin calendar year, days, days name (process reference code comment) according to sum

Note This special set of data:
4. Uayet 259
Positive solution is Ahau 364
Instead of Ahau 365
That is, if the given date corresponds to the last day of a year of the Tzolkin calendar, then the total number of days sum/260 the value of the year should be reduced by 1.
(Because although it has been a total of sum/260 years, the calendar indicates that the day is the last day of the previous year, so the year value sum/260 need to lose 1.)

Detailed code:

1#include <stdio.h>2 intFindhaabmonth (CharHaabmonth[]);//returns the ordinal of the month, based on the name of the month entered (1~19)3 Charhaabmonthnamedic[ -][ -]=4 {5      "Pop","No","Zip","Zotz","Tzec","XUL","Yoxkin","Mol","Chen","Yax","Zac","CEH",6      "mac","Kankin","Muan","Pax","Koyab","Cumhu","Uayet"7 };8 Chartzolkindaynamedic[ -][ -]=9 {Ten     "Imix","ik","Akbal","kan","Chicchan","Cimi","Manik","Lamat","Muluk","OK", One      "Chuen","EB","Ben","IX","Mem","CIB","Caban","Eznab","Canac","Ahau" A }; - intMain () - { the     intn,i; -     intHaabday;Charhaabmonth[ -];inthaabyear; -     intsum; -     intTzolkindaynumber;intTzolkindaynameindex;inttzolkinyear; +     inttemp; -  +scanf"%d",&n); Aprintf"%d\n", n); at      for(i=0; i<n;i++) -     { -sum=0; -scanf"%d.%s%d",&haabday,haabmonth,&haabyear); -  -         //converts the entered date to the number of days from the start point of the date inTemp=findhaabmonth (Haabmonth);//returns the ordinal of the month, based on the name of the month entered (1~19) -sum=haabyear*365+ (temp-1)* -+haabday+1; to         //This place temp-1 is to calculate the number of days temp-1 months prior to the first temp month; +         //haabday+1 is because the date number entered is starting at 0.  -  the  *         //then the corresponding Tzolkin calendar is calculated according to the sum of the year, the number of days, the day name $tzolkinyear=sum/260;//(Tzolkin year is 260 days per year)Panax Notoginseng  -tzolkindaynumber=sum% -;//the remainder sum%13 range is 0~12 the         if(tzolkindaynumber==0) tzolkindaynumber= -;//The number of days of the Tzolkin calendar is 1~13.  +         //The remainder is 1~12 can correspond directly to the number 1~12, but the remainder 0 should correspond to the number 13 (that is, the previous number period 1 to 13 of the same) A  thetzolkindaynameindex=sum% -;//the remainder sum%20 range is 0~19 +         if(tzolkindaynameindex==0) tzolkindaynameindex= -;//The line number of the day name of the Tzolkin calendar in the array tzolkindaynamedic[][] is 0~19 -         //The remainder 0 should correspond to that of the previous number period 1~20. $  $         if(tzolkindaynumber== -&&tzolkindaynameindex== -) tzolkinyear--; -         //if the given date corresponds to the last day of a year of the Tzolkin calendar, then the total number of days sum/260 the value of the year should be reduced by 1. -  theprintf"%d%s%d\n", tzolkindaynumber,tzolkindaynamedic[tzolkindaynameindex-1],tzolkinyear); -         //printf ("%d%d%d%d\n", sum,tzolkindaynumber,tzolkindaynameindex,tzolkinyear);Wuyi     } the     return 0; - } Wu intFindhaabmonth (CharHaabmonth[])//returns the ordinal of the month, based on the name of the month entered (1~19) - { About     inti; $      for(i=0;i< +; i++) -     { -         if(strcmp (haabmonth,haabmonthnamedic[i]) = =0) Break; -     } A     returni+1; +}

07: The Mayan Calendar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.