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 |
我靠,不会错吧 why?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator