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 ...
 
随机推荐
- Mysql双主  keepalived+lvs实现mysql高可用性
			
MySQL复制 能够保证数据的冗余的同时可以做读写分离来分担系统压力,如果是主主复制还可以很好的避免主节点的单点故障.但是MySQL主主复制存在一些问题无法满足我们的实际需要:未提供统一访问入口来实现 ...
 - 流式套接字:基于TCP协议的Socket网络编程(案例2)
			
案例:在案例1的基础上实现一个服务器对应多个客户端(多线程),且获得每个客户端的IP. 线程代码: package com.yh.mySocket; import java.io.BufferedRe ...
 - istio1.0.2配置
			
项目的组件相对比较复杂,原有的一些选项是靠 ConfigMap 以及 istioctl 分别调整的,现在通过重新设计的Helm Chart,安装选项用values.yml或者 helm 命令行的方式来 ...
 - JVM系列三:JVM参数设置
			
JVM系列三:JVM参数设置.分析 不管是YGC还是Full GC,GC过程中都会对导致程序运行中中断,正确的选择不同的GC策略,调整JVM.GC的参数,可以极大的减少由于GC工作,而导致的程序运 ...
 - vue之常用指令
			
事件缩写 v-on:click= 简写方式 @click= 事件对象$event <!DOCTYPE html> <html lang="en"> < ...
 - J-Link调试查看变量值总是显示<not in scope> 和<cannot evaluate>问题
			
原文:https://blog.csdn.net/gmpy_tiger/article/details/50395719 MDK/Keil 中,J-Link调试查看变量值总是显示<not in ...
 - PNS settings
			
Before PNS,some settings should be ready: firstly,make sure that the power/ground nets exist,if not, ...
 - Android Bundle传递对象
			
首先Android的Bundle是可以传递对象的.我们可以用Bundle b = new Bundle():b.putSerializable("key", 对象引用); 但是这样 ...
 - ASP.NET Core MVC 模型绑定 (转载)
			
ASP.NET Core MVC的Model Binding会将HTTP Request数据,以映射的方式对应到参数中.基本上跟ASP.NET MVC差不多,但能Binding的来源更多了一些.本篇将 ...
 - Django:admin后台汉化问题
			
1.设置admin站点中文显示,即汉化admin后台管理站点. 方法一:修改settings文件 LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' 更改为: LANG ...