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

我靠,不会错吧 why?

Posted by sunwen at 2007-11-05 14:45:19 on Problem 1701
#include<stdio.h>
#define N 10001
int main()
{
	int n;
	int i,j,c[N],a,b,t,r,m,k;
	__int64 sum,min=200000000; 
	scanf("%d",&n);
	while(n--)
	{
		min=200000000;
		scanf("%d%d%d",&m,&a,&b);
		for(i=0;i<m;i++)
			scanf("%d",&c[i]);
		for(i=0;i<m;i++)
		{
			sum=0;
			for(k=a,t=1,j=i-1;j>=0;j--,k+=a+t++)
			{
				if(c[j]==0)continue;
				sum+=c[j]*k;
			}
			for(k=b,t=1,j=i;j<m;j++,k+=b+t++)
			{
				if(c[j]==0)continue;
				sum+=c[j]*k;
			}
			if(sum<min)
			{
				min=sum;
				r=i;
			}
		}
		printf("%d\n",r+1);
	}
	return 0;
}

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