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 kare at 2006-08-05 11:20:48 on Problem 1008
#include<iostream>
#include<string.h>
using namespace std;
#define max 100
char hamon[19][8]={"pop","no","zip","zotz","tzec","xul","yoxkin",
                  "mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu"};
char tzolday[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk",
                    "ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
typedef struct{
	           int day;
			   char mon[10];
			   int year;
             }calendar;
int main()
{    int n,a[max];
     calendar  haab,tzolkin[max]; 
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{  int sum,k;
		scanf("%d. %s %d",&haab.day,haab.mon,&haab.year);
	 for(int j=0;j<19;j++)
		 if(!strcmp(haab.mon,hamon[j]))  {k=j;break;}
		 sum=haab.year*365+k*20+haab.day;
       tzolkin[i].year=sum/260;
	   a[i]=k;
       tzolkin[i].day=sum%13+1;
	}
	printf("%d\n",n);
	for(i=0;i<n;i++)
		printf("%d %s %d\n",tzolkin[i].day,tzolday[a[i]],tzolkin[i].year);
  return 1;
}


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