PersonalCorpus 版 (精华区)
Your C++ program has solved Ok the problem 591 (Box of Bricks)
in 0.010 seconds with low memory spent.
void main()
{
int i,j,k,n,t=0;
int a[50];
while(1) {
scanf("%d\n",&n); if (n==0) break;
printf("Set #%d\n",++t);
k=0; for (i=0;i<n;i++) { scanf("%d",&a[i]); k+=a[i]; }
k/=n; j=0; for (i=0;i<n;i++) j+=abs(k-a[i]);
printf("The minimum number of moves is %d.\n\n",j/2);
}
}
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.953毫秒