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

what's wrong?

Posted by mathsoft at 2006-03-03 21:42:48 on Problem 1701
#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:
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