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

各位高手麻烦帮我看下1701题我哪里错了

Posted by longriver at 2008-07-15 21:04:28
#include<iostream>
using namespace std;
void tracy(int a,int b,int m,int c[],double d[])
{
	double sum=0.0;	
	for(int i=1;i<=m;i++)
	{
		sum=0.0;
		for(int j=1;j<i;j++)
			sum+=((i-j)*b+0.5*(i-j)*(i-j-1))*c[j-1];
		for(int k=i+1;k<=m;k++)
			sum+=((k-i)*a+0.5*(k-i)*(k-i-1))*c[k-1];
		d[i-1]=sum;
		
	}
	
	
};


void swap(double A[],int i,int j)
{
	double temp=A[i];
	A[i]=A[j];
	A[j]=temp;

};

void inssort(double A[],int n)
{
	for(int i=0;i<n;i++)	
	  for(int j=i;(j>0)&&(A[j]<A[j-1]);j--)		
	   swap(A,j,j-1);
			
		
	
};


int main()
{
	int t;
	cin>>t;
	int* f=new int[t];
	int yao=0;
	int m,a,b;	
	cin>>m>>a>>b;
	int* c=new int[m];
	double* d=new double[m];
	double* e=new double[m];
	for(int i=0;i<m;i++)
	cin>>c[i];
	tracy(a,b,m,c,d);
	for(int k=0;k<m;k++)
		e[k]=d[k];
	inssort(d,m);
	for(int j=0;j<m;j++)
	{
		if(d[0]==e[j])
		{
			f[yao++]=j+1;
			//cout<<j+1<<endl;
			break;
		}
	}	
	for(int l=0;l<t;l++)
		cout<<f[l]<<endl;
	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