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 |
what's wrong?#include<stdio.h> int main() {int i,j,M,a,b,n,tenant[20],floor; double dis[10000],min; scanf("%d",&n); while(n--) {scanf("%d%d%d",&M,&a,&b); for(i=1;i<=M;i++) scanf("%d",&tenant[i]); dis[1]=0; for(j=1;j<=M;j++) dis[1]+=tenant[j]*(j-1)*(a+.5*(j-1-1)); min=dis[1];//printf("min=%lf,",min); for(i=1;i<=M;i++) dis[i]=0; for(i=1;i<=M;i++) {for(j=1;j<=M;j++) {if(j>=i) dis[i]+=tenant[j]*(j-i)*(a+.5*(j-i-1)); else dis[i]+=tenant[j]*(i-j)*(b+.5*(i-j-1));} //printf("dis=%lf\n",dis[i]); if(dis[i]<min) {min=dis[i];floor=i;} } printf("%d\n",floor); } getchar();getchar(); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator