HDU 2088 Box of Bricks
http://acm.hdu.edu.cn/showproblem.php?pid=2088

The total number of bricks will be divisible by the number of stacks. Thus, it is always possible to rearrange the bricks such that all stacks have the same height.
The input is terminated by a set starting with n = 0. This set should not be processed.
Output a blank line between each set.
#include <bits/stdc++.h>
using namespace std; int a[111]; int main()
{
int n;
int num=0;
while(~scanf("%d",&n)) {
if(n==0) break;
num++;
if(num>1) printf("\n");
long long sum=0;
for(int i=1; i<=n; i++) {
scanf("%d",&a[i]);
sum+=a[i];
}
int ave=sum/n;
int cnt=0;
for(int i=1; i<=n; i++) {
if(a[i]>ave)
cnt+=a[i]-ave;
}
printf("%d\n",cnt);
}
return 0;
}
HDU 2088 Box of Bricks的更多相关文章
- HDU 2088 Box of Bricks(脑洞)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2088 Box of Bricks Time Limit: 1000/1000 MS (Java/Oth ...
- 『嗨威说』算法设计与分析 - 贪心算法思想小结(HDU 2088 Box of Bricks)
本文索引目录: 一.贪心算法的基本思想以及个人理解 二.汽车加油问题的贪心选择性质 三.一道贪心算法题点拨升华贪心思想 四.结对编程情况 一.贪心算法的基本思想以及个人理解: 1.1 基本概念: 首先 ...
- HDOJ(HDU) 2088 Box of Bricks(平均值)
Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...
- HDU 1326 Box of Bricks(思维)
Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stac ...
- 杭电 2088 Box of Bricks
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2088 解题思路:一堆高度不同的砖块,需要把它们砌成一堵墙,即每一堆砖的高度相同(即砖的总数除以砖的堆数 ...
- HDU 1326 Box of Bricks(水~平均高度求最少移动砖)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1326 题目大意: 给n堵墙,每个墙的高度不同,求最少移动多少块转使得墙的的高度相同. 解题思路: 找到 ...
- 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 ...
随机推荐
- 更改Apache默认起始(索引)页面:DirectoryIndex
Apache默认索引页面是index.html,修改成其他文件需要修改httpd.conf文件: # # DirectoryIndex: sets the file that Apache will ...
- JavaScript中的箭头函数
1.定义 箭头函数相当于匿名函数,并且简化了函数定义.箭头函数有两种格式,一种像上面的,只包含一个表达式,连{ ... }和return都省略掉了.还有一种可以包含多条语句,这时候就不能省略{ ... ...
- P1312 Mayan游戏
题目描述 Mayan puzzle是最近流行起来的一个游戏.游戏界面是一个 7 行5 列的棋盘,上面堆放着一些方块,方块不能悬空堆放,即方块必须放在最下面一行,或者放在其他方块之上.游戏通关是指在规定 ...
- mysql的常用优化知识
索引类型:主键索引,唯一索引,联合索引,普通索引,全文索引 建立索引: create index index_name on table(field_name); 删除索引: drop index i ...
- SAP查询TABLE对应的文本表
SAP 取数时,通常配置项,需要取对应的文本描述,一般在配置表后加个T,就可以找到描述对应的表名. 但有时也有不符合这个规则的,例如生产订单类型数据表 T003O. 表名加T后并不存T003OT. 这 ...
- 【SQL】MaxComputer常用SQL与注意小结
MaxComputer常用SQL 1.建表 CREATE TABLE dwd_tfc_ctl_signal_phasedir ( cust_inter_id STRING COMMENT '客户路口I ...
- 在java代码中执行js脚本,实现计算出字符串“(1+2)*(1+3)”的结果
今天在公司项目中,发现一个计算运费的妙招.由于运费规则各种各样,因此写一个公式存到数据库.下次需要计算运费时,直接取出这个公式,把公式的未知变量给替换掉,然后计算出结果就是ok了. 一 ...
- Eclispe与JDK
一.Eclispe 1.1 Eclispe发布版本 下面是目前已知的版本代号 (Release)[2015年2月] Eclipse 3.1 版本代号 IO [木卫1,伊奥] Eclipse 3.2 版 ...
- 【转载】C++引用详解
原文:http://www.cnblogs.com/gw811/archive/2012/10/20/2732687.html 引用的概念 引用:就是某一变量(目标)的一个别名,对引用的操作与对变量直 ...
- 蓝牙inquiry流程之Advertising Report
setting 界面开始搜索的时候,通常也会同时进行le scan,这一点在inquiry流程之命令下发中已经讲述.此篇文章主要是分析一下对于controller 搜索到的广播包的处理.这里以Andr ...