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

为啥是Runtime error,那位给指点一下?

Posted by zhenly at 2006-09-07 11:47:20 on Problem 2772
#include<stdio.h>//把人看作是无差别的,只要箱子还没办完,人就不停的运动,而且每2f分钟就办完一个箱子,每2f分钟后状态会循环一次!!
void count(int n,int f,int b);//why is the runtime error
void main()
{
	int n,f,b,i=0,cases;
	scanf("%d",&cases);
	for(i=0;i<cases;i++)
	{
		scanf("%d%d%d",&n,&f,&b);
		count(n,f,b);      
	}
		
}
void count(int n,int f,int b)
{
	int j,time=0,l,k,p,w,temp,tup=0;
	int st[100];
	for(j=0;j<n;j++)
	{
		scanf("%d %d",&p,&w);
		if(w==0) //以循环的方式处理距离
			p=p;
		else
		{
			if(f-p>tup)
				tup=f-p;
			p=2*f-p;
		}
		st[j]=p;
	}
	for(l=n;l>=0;l--)// lazy sort
		for(k=0;k<l;k++)
		{
			if(st[k]<st[k+1])
			{
				temp=st[k+1];
				st[k+1]=st[k];
				st[k]=temp;
			}
		}
	l=b%n;
	if(l==0)
		time=b/n*2*f+tup;
	else
		time=b/n*2*f+st[l]+f;
    printf("%d\n",time);
}

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