ACM PKU 1477 Box of Bricks 简单题

http://acm.pku.edu.cn/JudgeOnline/problem?id=1477
Source

Problem Id:1477  User Id:lnmm
Memory:116K  Time:0MS
Language:C++  Result:Accepted

 1#include"iostream.h"
 2int a[51];
 3void main()
 4{
 5    int T;
 6    int i;
 7    int sum,avg;
 8    int c=0;
 9    while((cin>>T)&&T!=0)
10    {
11        sum=0;
12        avg=0;
13        for(i=1;i<=T;i++)
14        {cin>>a[i];
15        sum+=a[i];
16        }

17        avg=sum/T;
18        sum=0;
19        for(i=1;i<=T;i++)
20        {
21            if(a[i]>avg)sum=sum+a[i]-avg;
22        }

23        cout<<"Set #"<<++c<<endl;
24        cout<<"The minimum number of moves is "<<sum<<"."<<endl;
25        cout<<endl;
26    }

27
28
29
30}

31

posted on 2007-09-16 03:48 流牛ζ木马 阅读(470) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2007年9月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

导航

统计

公告

MY Email/MSN :mars1021@163.com QQ : 27402040 流牛ζ木马

常用链接

留言簿(6)

随笔档案

相册

搜索

最新随笔

最新评论

阅读排行榜

评论排行榜