Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我的代码,参考这个写的,觉得公式没错啊?谁能指点下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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator