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

Re:哪 位牛人可以帮帮小弟看一看是什么错误啊,十分感激!!!!!

Posted by 651914182 at 2007-11-24 15:57:58 on Problem 1701
In Reply To:哪 位牛人可以帮帮小弟看一看是什么错误啊,十分感激!!!!! Posted by:wo_top at 2007-11-24 09:56:31
> #include<stdio.h>
> #include<malloc.h>
> void main()
> { int cas,M,*floor,a,b,i=0,j=0,mark;
>   double sum,min=10000000;
>   scanf("%d",&cas);
>   for(i=1;i<=cas;i++)
>     { min=1000000;
> 	  scanf("%d%d%d",&M,&a,&b);
> 	  floor=(int *)malloc((M+1)*sizeof(int));
> 	  for(i=1;i<=M;i++)
> 	   scanf("%d",&floor[i]);
>       for(i=1;i<=M;i++)
> 	  {   sum=0;
>               for(j=1;j<=M-i;j++)
> 			  { sum+=floor[i+j]*(a*j+0.5*j*(j-1));
> 			  }
>               for(j=1;j<=i-1;j++)
> 			  { sum+=floor[i-j]*(b*j+0.5*j*(j-1));
> 			  }
> 			  if(min>sum)
> 			  { mark=i;
> 			    min=sum;
> 			  }
> 
> 		  }
> 	  printf("%d\n",mark);
> 	  free(floor);
> 	}
>   
> }

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