| ||||||||||
| 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 | |||||||||
各位高手麻烦帮我看下1701题我哪里错了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator