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 ...
随机推荐
- Spark学习之路 (二十二)SparkStreaming的官方文档
官网地址:http://spark.apache.org/docs/latest/streaming-programming-guide.html 一.简介 1.1 概述 Spark Streamin ...
- WorldWind源码剖析系列:星球球体的加载与渲染
WorldWind源码剖析系列:星球球体的加载与渲染 WorldWind中主函数Main()的分析 在文件WorldWind.cs中主函数Main()阐明了WorldWind的初始化运行机制(如图1所 ...
- opencv——对象计数
思路: 1.通过形态学操作.阈值处理.距离变换等方法,使得各个轮廓分开 2.计算轮廓数量 #include <opencv2/opencv.hpp> #include <iostr ...
- memset()初始化为1的那些事
问题代码: #include <stdio.h> #include <string.h> int main() { ]; int a; while(~scanf("% ...
- W25Q128BV W25Q128FV W25Q128JV 什么区别?
W25Q128BV W25Q128FV W25Q128JV 什么区别? 官网没有找到 BV 的相关信息, 倒是有 FV,FW,JV,JW 信息..2019年1月19日19:09:55 F ...
- 王立平--查看SQLite中的数据信息
Eclipse菜单Window - Open Perspective - DDMS进入DDMS视图. 然后File Explorer View中依次展开路径/data/data/package_nam ...
- 编译最新的SQLite 3.8.4.3为一个DLL
SQLite是一个小型数据库.特别适合于client应用程序使用,它的众多优点就不多说了.有兴趣的去搜索. 话说使用吧. 我们要使用.就须要调用它.如今一步一步来. 第一步:上SQLite官网http ...
- 文理分科 BZOJ3894 & happiness BZOJ2127
分析: 最小割(一开始我没看出来...后来经过提点,大致理解...),不选则割的思想. 我们先这样考虑,将和选理相关的和S相连,与选文相关的和T相连,如果没有第二问,那么建图就是简单的S连cnt,cn ...
- Storm 安装部署
环境要求JDK 1.6+java -versionPython 2.6.6+python -V ZooKeeper3.4.5+storm 0.9.4+ 单机模式上传解压 $ .tar.gz $ cd ...
- TPM及TSS协议栈的安装使用
TPM及TSS协议栈的安装 标签: 可信计算. 目录 安装环境介绍 TPM及TSS安装 软件包下载 TPM 安装 安装TSS 安装tpm-tools 交互过程 编写代码测试TPM是否可用 编写代码测试 ...