Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

惨痛的教训

Posted by mingrui at 2008-04-11 14:01:07 on Problem 1008
//p1008

#include<stdio.h>
char haab[19][3]={"po", "no", "zi", "zo", "tz", "xu", "yo", "mo", "ch", "ya", "za", "ce", "ma", "ka", "mu", "pa", "ko", "cu","ua"};
char tzolkin[20][9]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};

int main()
{
long int count;
unsigned int year,month,day,num,i,j,n;
char buff[9];
scanf("%u",&n);
printf("%u\n",n);
for(i=0;i<n;i++)
{
      scanf("%u.%s %u",&day,buff,&year);
      for(j=0;j<19;j++)
      {	
           if(buff[0]==haab[j][0]&&buff[1]==haab[j][1])
           {
              month=j;
              break;
           }
      }
     count=year*365+month*20+day+1;
     year=count/260;
     if(count%260!=0)
     {
      count%=260;
      num=(count-1)%13+1;
/*(count!=0)!!!这里要特别注意,把1~13+13n映射到1~13,而不是0~12(count%13),耗了我一个半小时*/
      day=(count-1)%20;
     }
     else
     {
      year--;
      num=13;
      day=19;
     }
     printf("%u %s %u\n",num,&tzolkin[day][0],year);
}
return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator