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 qing1952003 at 2007-05-05 16:40:03 on Problem 3232
	bool ok(__int64 t)
	{
		int i;
		__int64 tmp=0;
		for(i=0;i<n;i++)
		{
			if (a[i]-t<=0)
				continue;
			if ((a[i]-t)%(k-1)==0)
				tmp+=(a[i]-t)/(k-1);
			else
				tmp+=(a[i]-t)/(k-1)+1;
		}
		if (tmp<=t*m)
			return true;
		else
			return false;
	}
这样写只错了一组数据,但是下面那样写就不会错,为什么啊???
	bool ok(__int64 t)
	{
		int i;
		__int64 tmp=0,j=m*t;
		for(i=0;i<n;i++)
		{
			if (a[i]-t<=0)
				continue;
			if ((a[i]-t)%(k-1)==0)
				tmp=(a[i]-t)/(k-1);
			else
				tmp=(a[i]-t)/(k-1)+1;
			
			if (tmp>t||tmp>j)
				return false;
			j-=tmp;
		}
		return true;
	}

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