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 150014 at 2007-03-16 14:57:03 on Problem 1701
In Reply To:我的程序有什么错? Posted by:XieWenlei at 2004-07-18 20:57:49
#include<stdio.h>

void main()
{
	int iCaseNum,iFloorNum,iFloor[11000],iUp,iDown,iSum,iAdd,i,iMin;
	__int64 iLeft[11000],iRight[11000];
	scanf("%d",&iCaseNum);
	while(iCaseNum--)
	{
		scanf("%d%d%d",&iFloorNum,&iUp,&iDown);
		for(i=0;i<iFloorNum;i++)
			scanf("%d",&iFloor[i]);
		iLeft[0]=iAdd=0;
		iSum=iFloor[0];
		for(i=1;i<iFloorNum;i++)
		{
			iLeft[i]=iLeft[i-1]+iUp*iSum+iAdd;
			iAdd+=iSum;
			iSum+=iFloor[i];
		}
		iRight[iFloorNum-1]=iAdd=0;
		iSum=iFloor[iFloorNum-1];
		for(i=iFloorNum-2;i>=0;i--)
		{
			iRight[i]=iRight[i+1]+iDown*iSum+iAdd;
			iAdd+=iSum;
			iSum+=iFloor[i];
		}
		iMin=0;
		for(i=1;i<iFloorNum;i++)
			if(iLeft[i]+iRight[i]<iLeft[iMin]+iRight[iMin])
				iMin=i;
		printf("%d\n",iMin+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