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 that the Maya civilization used a 365 day long year, called Haab, which had 19 months. Each of the first 18 months was 20 days 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 having names, the days of the months were denoted by numbers starting from 0 to 19. The last month of Haab was called uayet and had 5 days denoted by numbers 0, 1, 2, 3, 4. The Maya believed that this month was unlucky, the court of justice was not in session, the trade stopped, people did not even sweep the floor.

For religious purposes, the Maya used another calendar in which the year was called Tzolkin (holly year). The year was divided into thirteen periods, each 20 days long. Each day was denoted by a pair consisting of a number and the name of the day. They used 20 names: imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau and 13 numbers; both in cycles.

Notice that each day has 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, 10 ok, 11 chuen, 12 eb, 13 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, 10 akbal . . .

Years (both Haab and Tzolkin) were denoted by numbers 0, 1, : : : , where the number 0 was the beginning of the world. Thus, the first day was:

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 is 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, each in separate line. The year is smaller then 5000.
Output
The date in Tzolkin should be 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 are dates in the Tzolkin calendar format, in the order corresponding to the input dates.
Sample Input
3
10. zac 0
0. pop 0
10. zac 1995
Sample Output
3
3 chuen 0
1 imix 0
9 cimi 2801
C语言版本

  #include <stdio.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int dycti(char num){
			switch(num){		
		case '0':return 0;
		case '1':return 1;
		case '2':return 2;
		case '3':return 3;
		case '4':return 4;
		case '5':return 5;
		case '6':return 6;
		case '7':return 7;
		case '8':return 8;
		case '9':return 9;
	}


}
int msti(char str[10]){
	
	if(strcmp(str,"pop")==0)	return 0;
	if(strcmp(str,"no")==0)		return 1;
	if(strcmp(str,"zip")==0)	return 2;
	if(strcmp(str, "zotz")==0)	return 3;
	if(strcmp(str,"tzec")==0)	return 4;
	if(strcmp(str,"xul")==0)	return 5;
	if(strcmp(str,"yoxkin")==0)	return 6;
	if(strcmp(str,"mol")==0)	return 7;
	if(strcmp(str,"chen")==0)	return 8;
	if(strcmp(str,"yax")==0)	return 9;
	if(strcmp(str,"zac")==0)	return 10;
	if(strcmp(str,"ceh")==0)	return 11;
	if(strcmp(str,"mac")==0)	return 12;
	if(strcmp(str,"kankin")==0)	return 13;
	if(strcmp(str,"muan")==0)	return 14;
	if(strcmp(str,"pax")==0)	return 15;
	if(strcmp(str,"koyab")==0)	return 16;
	if(strcmp(str,"cumhu")==0)	return 17;
	if(strcmp(str,"uayet")==0)	return 18;
	
}
char mstr[20][10]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" };
int main(int argc, char** argv) {
	 int n;
    scanf("%d",&n);
    getchar();
    char str[5000][20];
    int sum[5000];
    int i;
	char day[5000][5],month[5000][10],year[5000][5];
	
	printf("%d\n",n); 
	
    for(i=1;i<=n;i++){
    	gets(str[i]);
	    int d=0,m=0,y=0;
        int j;	
        //提取日 
        for(j=0;str[i][j]!='.';j++){
            d=d*10+dycti(str[i][j]);
        }
        j++;
        j++;
        int flag=j;
        //提取月 
        for(;str[i][j]!=' ';j++){
            month[i][j-flag]=str[i][j];
        }
        month[i][j]='\0';
        m=msti(month[i]);
        j++;
        //提取年 
        for(;str[i][j]!='\0';j++){
            y=y*10+dycti(str[i][j]);
        }
        //计算总天数 
        sum[i]=y*365+m*20+d;
        //输出 
        printf("%d %s %d\n",(sum[i]%260)%13+1,mstr[(sum[i]%260)%20],sum[i]/260);        
	}   
  return 0;
}

C++版本

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#define exp 1e-6
#define pi acos(-1.0)
using namespace std;
char c[20][20]= {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"};
char str[25][20]= {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
char s[100];
int reach(char *s)
{
    for(int i=0; i<19; i++)
        if(strcmp(s,c[i])==0)
            return i;
    return 0;
}
void build(int n)
{
    strcpy(s,str[n]);
}
int main()
{
    int T;
    int day,year;
    int sum;
 
    scanf("%d",&T);
    printf("%d\n",T);
    while(T--)
    {
        scanf("%d. %s %d",&day,s,&year);
        sum=year*365+reach(s)*20+day;
        year=sum/260;
        build(sum%20);
        day=(sum%13)+1;
        cout<<day<<" "<<s<<" "<<year<<endl;
    }
    return 0;
}