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

哪位高手指点一下,是不是有什么BT数据,为什么总是TLE?原码如下:

Posted by siah at 2005-12-31 21:39:45 on Problem 1010
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

int isrc;
int iarr[26],iarr1[1000],ipos[1000],icount;
int iresultarr[5],iresnum,iposarr[5],iresultarr1[5],itypenum,itypetemp;
int	trueflg,tieflg,itest1,itest2;

int cmp(const void *arg1,const void *arg2)
{
	return *(int *)arg1-*(int *)arg2;
}
int dealA(int istart,int inum)
{
	int i,iret;
	if(inum<iarr[istart]||(inum >((4-iresnum)*iarr[icount-1])))							/*found*/
	{
		return 0;
	}
	for(i=istart;i<icount;i++)
	{
		if(itypenum==4&&tieflg==1)
			break;
		if(inum<iarr[i])
		{
			return 0;
		}
		if((i!=istart)||(iresnum==0))
			itypetemp++;
		iresnum++;
		if(inum==iarr[i])							/*found*/
		{
			if(itypenum<itypetemp)
			{
				iresultarr[iresnum]=iarr[i];
				iresultarr[0]=iresnum;
				memcpy(iresultarr1,iresultarr,sizeof(int)*5);
				itypenum=itypetemp;
				trueflg=1;
				tieflg=0;	
			}
			else if(itypenum==itypetemp)
			{
				if(iresnum<iresultarr1[0])
				{
					iresultarr[iresnum]=iarr[i];
					iresultarr[0]=iresnum;
					memcpy(iresultarr1,iresultarr,sizeof(int)*5);
					itypenum=itypetemp;
					trueflg=1;
					tieflg=0;
				}
				else if(iresnum==iresultarr1[0])
				{
					tieflg=1;
					trueflg=0;
				}
			}
			iresnum--;
			if((i!=istart)||(iresnum==0))
				itypetemp--;
			continue;
		}
		if(iresnum<4)
		{
				iresultarr[iresnum]=iarr[i];
				dealA(i,inum-iarr[i]);			/*next*/
		}
		iresnum--;
		if((i!=istart)||(iresnum==0))
			itypetemp--;
	}
	return 0;
}
void deal()
{
	int i,iret;
	itypenum=0;
	iresnum=0;
	tieflg=0;
	trueflg=0;
	itypetemp=0;
	iresultarr[0]=-1;
	dealA(0,isrc);
	if(trueflg==0&&tieflg==0)
		printf("%d ---- none\n",isrc);
	else if(trueflg==1)
	{
		printf("%d (%d): ",isrc,itypenum);
		for(i=1;i<=iresultarr1[0];i++)
			printf("%d ",iresultarr1[i]);
		printf("\n");
	}
	else
	{
		printf("%d (%d): tie\n",isrc,itypenum);
	}
}
int main()
{
	int i,k=0;
	while(1)
	{
		icount=0;
		while(scanf("%d",&iarr[icount]))
		{
			if(iarr[icount]==0)
				break;
			icount++;
		}
		qsort(iarr,icount,sizeof(int),cmp);
		while(scanf("%d",&isrc))
		{
			if(isrc==0)
				break;
			if((((iarr[icount-1]*4)<isrc))||(isrc<iarr[0]))
			{
				printf("%d ---- none\n",isrc);
				continue;
			}
			deal();
		}
	}
}

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