BNU Box of Bricks
http://www.bnuoj.com/bnuoj/problem_show.php?pid=1596
#include<iostream>
#include<cstdio>
#include<algorithm> using namespace std; bool cmp(int a, int b)
{
return a<b;
} int main()
{
int n,i,k,sum,p;
int a[55];
k = 0;
while(scanf("%d",&n)&&n)
{
k++;
sum = 0;
for(i = 0; i < n; i++)
{
scanf("%d",&a[i]);
sum += a[i];
}
sum = sum/n;
sort(a,a+n,cmp);
p = 0;
for(i = 0; i < n; i++)
{
if(a[i] < sum)
{
p+=(sum-a[i]);
}
else
{
break;
}
}
printf("Set #%d\n",k);
printf("The minimum number of moves is %d.\n\n",p);
} return 0;
}
BNU Box of Bricks的更多相关文章
- HDOJ 1326. Box of Bricks 纯水题
Box of Bricks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- Box of Bricks最小移动砖块数目
Description Little Bob likes playing with his box of bricks. He puts the bricks one upon another and ...
- [POJ1477]Box of Bricks
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19503 Accepted: 7871 Description Litt ...
- HDOJ(HDU) 2088 Box of Bricks(平均值)
Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...
- HDOJ 1326 Box of Bricks(简单题)
Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...
- 591 - Box of Bricks
Box of Bricks Little Bob likes playing with his box of bricks. He puts the bricks one upon another ...
- Box of Bricks
Box of Bricks Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- HDU 2088 Box of Bricks
http://acm.hdu.edu.cn/showproblem.php?pid=2088 Problem Description Little Bob likes playing with his ...
- HDU 2088 Box of Bricks(脑洞)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2088 Box of Bricks Time Limit: 1000/1000 MS (Java/Oth ...
随机推荐
- Aptana Studio 3 官方汉化包汉化
Babel Language Pack Update Site for Helios This URL is an Eclipse software repository:http://downloa ...
- 我的Python成长之路---第七天---Python基础(22)---2016年2月27日(晴)
socket网络编程 socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求. ...
- 转: 用css把图片转为灰色图
小tip: 使用CSS将图片转换成黑白(灰色.置灰) by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.co ...
- CSS中border-style的属性
属性可能的值 值 描述 none 定义无边框. hidden 与 "none" 相同.不过应用于表时除外,对于表,hidden 用于解决边框冲突. dotted 定义点状边框.在大 ...
- UVA 270 Lining Up 共线点 暴力
题意:给出几个点的位置,问一条直线最多能连过几个点. 只要枚举每两个点组成的直线,然后找直线上的点数,更新最大值即可. 我这样做过于暴力,2.7s让人心惊肉跳...应该还能继续剪枝的,同一直线找过之后 ...
- Jquery Ajax时 error处理 之 parsererror
Jquery Ajax时 error处理 之 parsererror 01 $.ajax({ 02 type: "POST", 03 con ...
- TCP/IP之DNS域名解析系统
DNS系统是一个分布式的数据库,当一个数据库发现自己并没有某查询所需要的数据的时候,它将把查询转发出去,而转发的目的地通常是根服务器,根服 务器从上至下层层转发查询,直到找到目标为止.DNS还有一个特 ...
- 倒计时IE10+
直接上代码,dome 里边有我做的列表倒计时(多个同时倒计时)下面是我做的例子,颜色可以自己设置的 <p name="daojishi" style="width: ...
- ViewPager实现广告自动轮播核心代码(Handler+Thread)
ViewPager数据源是4个线性布局,每个布局里面充满一张高度固定.宽度充满父布局的图片.有4个小圆点跟随ViewPager滑动.轮播原本我是用Timer+TimerTask的,但是问题颇多,很是郁 ...
- linux下编码和vim编码问题解决
Linux下编码问题 在Linux环境下经常会出现文件乱码的问题,这实际上就是因为文件编码,以Ubuntu为例,默认的字符编码为UTF-8,并且没有默认安装gbk和gb2312,所以需要我们进行安装和 ...