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 |
程序有什么错误#include<iostream> using namespace std; int aa[10000]; double up[10000]; double down[10000]; int N,a,b; int nPos=1; void UpSum() { double pcount=aa[N-1]; double addnum=0; up[0]=0; for(int i=0;i<N-1;i++) { up[i+1]=up[i]+pcount*a+addnum; addnum+=pcount; pcount+=aa[N-i-2]; } } void DownSum() { double pcount=aa[0]; double addnum=0; down[0]=0; for(int i=0;i<N-1;i++) { down[i+1]=down[i]+pcount*b+addnum; addnum+=pcount; pcount+=aa[i+1]; } } void FindSoul() { double best=down[0]+up[N-1]; for(int i=0;i<N;i++) { if(down[i]+up[N-i-1]<best) { best=down[i]+up[N-i-1]; nPos=i+1; } } } void main() { int M; cin>>M; if(M>20||M<1) return; for(int jj=0;jj<M;jj++) { cin>>N>>a>>b; if(a>100||a<0||b>100||b<0) return; if(N>10000||N<=0) return; for(int i=0;i<N;i++) { cin>>aa[i]; if(aa[i]>20||aa[i]<0) return; } DownSum(); UpSum(); FindSoul(); cout<<nPos<<endl; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator