[problem description]

During his academic vacation, Professor M.A. Ya made an amazing discovery on the ancient Maya calendar. From an old and tricky message, the professor found that Maya civilization takes 365 days as a year, called Haab, and contains 19 months. The first 18 months have 20 days each month. The names of the months are pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab and cumhu. The number of days per month is expressed in numbers, from 0 to 19, not by name. The last month of Haab is called uayet, which has five days, expressed as 0, 1, 2, 3 and 4. The Mayans thought this month was unlucky, the courts were closed, trade stopped, and people even stopped cleaning the floor.

For religious purposes, Maya people use another calendar, It is called Tzolkin (Winter Youth). A year is divided into 13 periods, each of which is 20 days. Every day is expressed as a number pair represented by numbers and date names. 20 names are used: imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau, and 13 numbers, which are used in double circulation.

Please note that every day has a clear description. For example, the day at the beginning of the year is 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, 8 imix, 9 ik, 10 akbal

Year (including Haab and Tzolkin) with numbers 0, 1 The number 0 is the beginning of the world. Therefore, the first day is expressed as:

Haab: 0. pop 0

Tzolkin: 1 imix 0

Please help Professor M.A.Ya write a program to convert Haab calendar into Tzolkin calendar.

[input form]

In Haab, the date is expressed in the following form:

NumberOfTheDay. Month Year

The first line of the input file contains the number of input dates in the file. The next N lines contain n dates in Haab calendar format, and the year is less than 5000.

[output form]

Tzolkin dates are in the following format:

Number NameOfTheDay Year

The output includes n lines. The date in tzolkin calendar format is output in the order corresponding to the input date.

[sample input]

3

10.zac 0

0.pop 0

10.zac 1995

[sample output]

3 chuen 0

1 imix 0

9 cimi 2801

Problem solving

Idea: calculate the total number of days, and then calculate and process according to Tzolkin's rules.

sumday=pp[t].num1*365+haab(pp[t].str3)*20+pp[t].num+1;//Calculate total days

int year=0,save=0; year=sumday/260;//Year of calculation save=sumday%260;//Part less than one year int k1=0,k2=0; for(int i=0;i<save;i++){ if(k1<14) k1++; if(k1==14) k1=1;//Turn back 1 to 13 if(k2<21) k2++; if(k2==21) k2=1;//20 turn back to 1 as the subscript of str1 and find the name of the corresponding day } cout<<k1<<" "<<str1[k2-1]<<" "<<year<<endl;

Full code:

#include <iostream> #include<bits/stdc++.h> using namespace std; string str0[19]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen",//Month corresponding to haab "yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhn","uayet"}; string str1[20]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat",//Tzolkin corresponds to the name of each day "muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"}; int haab(string str){//Calculate the corresponding month for(int i=0;i<19;i++){ if(str0[i]==str) return i; } } struct exmp{//It is used to input the time in the form of haab, avoiding the processing of string int num;//day char ch;//"." string str3;//month int num1;//year }; int main() { int n; cin>>n; exmp pp[n]; int t=0; while(n--){ cin>>pp[t].num>>pp[t].ch>>pp[t].str3>>pp[t].num1; long long int sumday=0; sumday=pp[t].num1*365+haab(pp[t].str3)*20+pp[t].num+1;//Calculate total days int year=0,save=0; year=sumday/260;//Year of calculation save=sumday%260;//Part less than one year int k1=0,k2=0; for(int i=0;i<save;i++){ if(k1<14) k1++; if(k1==14) k1=1;//Turn back 1 to 13 if(k2<21) k2++; if(k2==21) k2=1;//20 turn back to 1 as the subscript of str1 and find the name of the corresponding day } cout<<k1<<" "<<str1[k2-1]<<" "<<year<<endl; t++; } return 0; }