1. Description of the problem
Mayan Calendar
Time Limit: 1000MS |
|
Memory Limit: 10000K |
Total submissions: 80876 |
|
accepted: 24862 |
Description last weekend, Professor M.a-ya had a great discovery about the old Maya. From an ancient knot (the Mayan tool for remembering), the professor found that the Mayan people used a 365-day calendar called Haab in one year. 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 represented by 0 to 19. The last one months of the Haab calendar are called Uayet, and it's only 5 days, 0 to 4. The Mayan people think that the month with the fewest dates is unlucky, that the court is not sitting this month, people are not engaged in trading, and no one even cleans the floor in the house.
Because of religious reasons, the Maya also used another calendar, in which the calendar is called Tzolkin (Holly Years), and is divided into 13 different periods a year, each of which has 20 days, each of which is represented by a number and a combination of words each day. 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, OK, Chuen, EB, Ben, 1 IX, 2 mem, 3 CIB, 4 Caban, 5 Eznab, 6 Canac, 7 Ahau,, 8 Imix, 9 ik, Akbal ... This means that numbers and words are used independently.
The years in the Haab calendar and Tzolkin calendar are in numbers 0, 1, ... said 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 writes a program that converts the Haab calendar into a Tzolkin calendar.
The data in the Input Haab calendar is represented in the following manner:
Date. Year of the Month
The first line in the input represents the amount of data to convert to the Haab calendar date. Each of the following lines represents a date, and the number of years is less than 5000.
The data in the Output Tzolkin calendar is represented in the following manner:
Days Digital Day name number of 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
3
Zac 0
0 pops 0
Zac 1995
Sample Output
3
3 Chuen 0
1 Imix 0
9 Cimi 2801
2. Select data Structure
Select the string array to store the "month of the Mayan calendar" and the "day name of the Tzolkin calendar", and select the string type variable dot to receive the "." After the int type.
3. Core code block
#include <iostream> #include <string> #include <algorithm> using namespace std; String Maya[20] = {"Pop", "No", "zip", "Zotz", "Tzec", "Xul", "Yoxkin", "mol", "Chen", "Yax", "Zac", "CEH", "Mac",
"Kankin", "Muan", "Pax", "Koyab", "Cumhu", "Uayet", ""}; String Holly[20] = {"Ahau", "Imix", "ik", "Akbal", "Kan", "Chicchan", "Cimi", "Manik", "Lamat", "Muluk", "OK", "Chu
En, "EB", "Ben", "IX", "Mem", "CIB", "Caban", "Eznab", "Canac"};
String Strmonth;
string dot;
int days = 0;
int month = 0;
int years = 0;
void Stdinput ();
void StdOut (int args);
int main () {int num = 0;
CIN >> Num;
cout << num << endl;
Receive "." With Dot.
while ((num--) && (cin >> days >> dot >> strmonth >> years)) {stdinput ();
int total = years*365 + month*20 + 1;;
StdOut (total);
return 0;
void Stdinput () {for (int i = 0; i < i++) {if (Strmonth = = Maya[i]) {month = i;
Break }} void StdOut (int args{//holly days starting from 1 int hyears = args/260;
int num = args% 260;
if (num = = 0) {hyears = 1;
cout << "" << "Ahau" << hyears << Endl;
else {int hdaysnum = num% 13;
if (Hdaysnum = = 0) {hdaysnum = 13;
} cout << hdaysnum << "" << holly[num%20] << "" << hyears << Endl; }
}
Another solution
#include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> using namespace std;
int main () {//freopen ("In.txt", "R", stdin); Char h[20][10]={"", "Pop", "No", "zip", "Zotz", "Tzec", "Xul", "Yoxkin", "mol", "Chen", "Yax", "Zac", "CEH", "Mac", "Kankin",
"Muan", "Pax", "Koyab", "Cumhu", "Uayet"}; Char t[21][10]={"", "Imix", "ik", "Akbal", "Kan", "Chicchan", "Cimi", "Manik", "Lamat", "Muluk", "OK", "Chuen", "EB", "Ben",
"IX", "Mem", "CIB", "Caban", "Eznab", "Canac", "Ahau"};
int time;
cin>>time;
cout<<time<<endl;
int sum,hy,hd,ty,tm,td;
Char dot[10],str[10];
while (time--) {sum=0;
cin>>hd>>dot>>str>>hy;
SUM+=HD;
int i;
for (i=1;i<=20;i++) {if (strcmp (str,h[i)) ==0) break;
} sum+= (i-1) *20;
sum+=hy*365;
td=sum%13+1;
tm=sum%20+1;
ty=sum/260; cout<<td<< "" <<t[tm]<< " "<<ty<<endl;
return 0; }