| ||||||||||
| 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 | |||||||||
Re:这题判定的不严aIn Reply To:这题判定的不严a Posted by:jxwking2010 at 2006-07-24 20:43:34 要是只用意移一步
应输出 The minimum number of move is 1 是move 而不是moves 还用空行,不安他说的也AC了。。。。。我无语
#include <stdio.h>
#include <math.h>
int main()
{
int n,h;
int a[100];
int i,j=0,k,sum;
while(0!=scanf("%d",&n))
{
if(n==0)break;
sum=0;
for(i=0;i<n;i++) //input
{
scanf("%d",&a[i]);
sum+=a[i];
}
h=sum/n;
k=0;
for(i=0;i<n;i++)
{
k+=fabs(h-a[i]);
}
j++;
if(j>1)printf("\n");
printf("Set #%d\n",j);
printf("The minimum number of moves is %d.\n",k/2);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator