2009-01-25 15:25:27來源不明
ACM 591 Box of Bricks
/***********************************************************/
- #include<stdio.h>
- #include<stdlib.h>
- main()
- {
- int a,b,c,n,time=0;
- while(scanf("%d",&n)==1&&n!=0)
- {
- time++;
- int sum=0,m,temp[100]={0},ans=0;
- for(a=0;a<n;a++)
- {
- scanf("%d",&m);
- sum=sum+m;
- temp[a]=m;
- }
- sum=sum/n;
- for(a=0;a<n;a++)
- {
- if(temp[a]<sum)
- {
- ans=ans+sum-temp[a];
- }
- }
- printf("Set #%d\n",time);
- printf("The minimum number of moves is %d.\n",ans);
- }
- return 0;
- }