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 ...
随机推荐
- oneinstack远程管理数据库
本篇文章主要内容是本地工具连接数据非网页(网站)连接 如果你想使用网页(网站)连接远程数据库,请看下面的官网教程 OneinStack如何配置MySQL远程连接? 为了安全考虑,OneinStack仅 ...
- oracle kill 锁
select object_name as 对象名称,s.sid,s.serial#,p.spid as 系统进程号 from v$locked_object l , dba_objects o , ...
- P2384 最短路
题目背景 狗哥做烂了最短路,突然机智的考了Bosh一道,没想到把Bosh考住了...你能帮Bosh解决吗? 他会给你100000000000000000000000000000000000%10金币w ...
- python获得命令行参数的方法
#encoding=utf8 import sys reload(sys) sys.setdefaultencoding("utf8") print "参数名: &quo ...
- Centos7-安装Gradle4.10
1.下载 官方安装文档:https://gradle.org/install/ 官方下载地址:http://services.gradle.org/distributions/gradle-4.10- ...
- Feeling_2018_5_22
“我打你,你会走吗?” “不会!!” “我骂你,你会走吗?” “不会!!” “那我不爱你了,你会走吗?” “会.”
- cache-fusion笔记
GRD (global resource directory)保存着所有实例中资源的分布情况 GCS (global cache service)具体执行cache fusion 工作的服务,对应 ...
- Swoole Task 的应用
目录 概述 代码 小结 扩展 参考文档 概述 Swoole 异步Task,主要实现调用异步任务的执行. 常用的场景:异步支付处理.异步订单处理.异步日志处理.异步发送邮件/短信等. Swoole 的实 ...
- 20155217《网络对抗》Exp04 恶意代码分析
20155217<网络对抗>Exp04 恶意代码分析 实践内容 使用schtasks指令监控系统运行 使用sysmon工具监控系统运行 使用virscan分析恶意软件 使用systrace ...
- 20155239吕宇轩 Exp1 PC平台逆向破解(5)M
20155239 网络对抗 Exp1 PC平台逆向破解(5)M 实验内容 (1).掌握NOP, JNE, JE, JMP, CMP汇编指令的机器码(1分) (2)掌握反汇编与十六进制编程器 (1分) ...