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 ...
随机推荐
- Jsp中使用EL表达式对字符串进行操作
用fn函数:<%@ taglib prefix="fn" uri="http://Java.sun.com/jsp/jstl/functions" %&g ...
- ListView列表项
方法,在xml文件中添加一个ListView,然后在MainActivity中 private ListView listView; private ArrayAdapter<String> ...
- 我在网站开发中经常用到的几个js函数01
这是我在最近的一个网站项目中频繁用到的几个js函数,非常实用.包括:1.js获取地址栏参数:2.返回cookies字符串中指定键对应的值:3.json格式的日期转换为正常格式4.清除cookie. / ...
- Cannot mix incompatible Qt library (version 0x40801) with this library (version 0x40804)
安装EMAN2(单颗粒重构的软件)之后,运行e2projectmanager.py来启动程序出现了这个错误. 去网上找了一下,发现一个靠谱的方案,这个问题出现是由于EMAN2这个程序自带了Qt的库,而 ...
- centos下卸载jdk
链接地址:http://blog.csdn.net/shuixin536/article/details/8954011 http://sunqiusong.email.blog.163.com/bl ...
- Linux下载文件时报错 To connect to ohse.de insecurely, use ‘--no-check-certificate’.
远程调用下载文件直接用wget就可以,一般文件路径类型是http.如果有遇到是https就会下载出错. 错误如下: [root@vmu010226-node1 tmp]# wget https://w ...
- CSS技巧!像table一样布局div
摘自:http://www.cnblogs.com/hnyei/archive/2011/09/19/2181442.html 许多网页设计师都喜欢,将两个或者多个容器等高的并排放置,并在里面展示每个 ...
- nginx 配置日志
http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $r ...
- 【C++继承与派生之二】有子对象的派生类的构造函数
这是我今天看书刚刚看到的,觉着以前对这一块内容了解不多,所以整理一下分享给大家.首先要介绍一下子对象的概念.类的数据成员不仅可以是int.char这样的基本类型,也可以是类对象,如可以包含这样的数据成 ...
- ActionBar点击弹出下拉框操作
首先: getActionBar().setDisplayShowTitleEnabled(false); ActionBar.LayoutParams lp = new ActionBar.Layo ...