HDU 2088 Box of Bricks(脑洞)
传送门:
http://acm.hdu.edu.cn/showproblem.php?pid=2088
Box of Bricks
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 20219 Accepted Submission(s): 6473

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.
5 2 4 1 7 5
0
code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define max_v 50
int a[max_v];
int main()
{
int n,k=;
while(~scanf("%d",&n))
{
if(n==)
break;
if(k)
printf("\n");//注意输出格式,最后一个测试不能有空行
int sum=;
for(int i=; i<n; i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
sum/=n;//平均
int c=;
for(int i=; i<n; i++)
{
if(a[i]<sum)//小于平均的栈其差多少的和就是需要移动的总数
c+=(sum-a[i]);
}
printf("%d\n",c);
k++;
}
return ;
}
HDU 2088 Box of Bricks(脑洞)的更多相关文章
- 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)
本文索引目录: 一.贪心算法的基本思想以及个人理解 二.汽车加油问题的贪心选择性质 三.一道贪心算法题点拨升华贪心思想 四.结对编程情况 一.贪心算法的基本思想以及个人理解: 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 ...
随机推荐
- JS 面向对象之继承---多种组合继承
1. 组合继承:又叫伪经典继承,是指将原型链和借用构造函数技术组合在一块的一种继承方式. 下面来看一个例子: function SuperType(name) { this.name = name; ...
- 将ojdbc 添加到maven
去oracle官网下载jar包 然后在jar包所在目录输入maven命令 mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdb ...
- Hnoi2004 金属包裹
传送门 三维凸包模板题……只是听了听计算几何的课之后心血来潮想写的…… 我的做法很无脑是吧……暴力枚举三个点组成的三角形,然后枚举剩下的点,判断其余点是否都在这个三角形的同一侧,是的话则说明这个三角形 ...
- npm属性笔记
scripts属性,运行脚本命令的npm命令行缩写,常见如下npm run devnpm run startnpm run build dependencies属性,项目运行时配置模块依赖的模块列表, ...
- Python-正则表达式实现计算器功能
需求: 用户输入运算表达式,终端显示计算结果 源代码: # !/usr/bin/env/ python3 # -*- coding: utf-8 -*- """用户输入计 ...
- 使用Axure管理团队项目以及分享原型
第一部分:使用Axure管理团队项目 首先,你要有一个Axure账户 呵呵哒.注册地址:http://share.axure.com 发起团队项目 在浏览器登录 Axure share(网速很卡很卡) ...
- golang闭包
http://blog.51cto.com/speakingbaicai/1703229 https://www.jianshu.com/p/fa21e6fada70 所谓闭包就是一个函数" ...
- linux系统开机突然黑屏,只有光标
以前系统都是好好的,今天开机黑屏了,只有一个光标可以看见其他东西都看不见了. 经过检查发现是磁盘满了,将不用的文件删除之后可以正常开机了.特此记录一下!!! 有人问黑屏了怎么删文件? 我采用的方法是W ...
- AutoHotkey的函数对象的Bind方法绑定参数的应用
近期在写Excel数据批处理函数,想提取某列的每个数据是否匹配某某条件的所有单元格. 这种需求比较多,比如判断的值有:单元格值,字体颜色,单元格颜色等等, 判断条件有:相同,不同,正则,或在某多行字符 ...
- yii2.0发送qq邮件详情配置
首先要想使用qq发送邮件必须打开使用的qq邮箱里的一个配置,