[POJ1477]Box of Bricks
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 19503 | Accepted: 7871 |
Description
Input
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
Output a blank line after each set.
Sample Input
6
5 2 4 1 7 5
0
Sample Output
Set #1
The minimum number of moves is 5.
Source
THINKING
贪心,先计算平均值,再扫描数组求出差值,注意句末的句号和组数之间的空行!
var a:array[..] of longint;
n,i,sum,summ,t:longint;
begin
summ:=;
while true do
begin
fillchar(a,sizeof(a),);
sum:=;
t:=;
readln(n);
if n= then halt;
for i:= to n do
begin
read(a[i]);
inc(sum,a[i]);
end;
sum:=sum div n;
for i:= to n do
t:=abs(sum-a[i])+t;
writeln('Set #',summ);
writeln('The minimum number of moves is ',t div ,'.');
writeln;
inc(summ);
end;
end.
[POJ1477]Box of Bricks的更多相关文章
- 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 ...
- HDOJ(HDU) 2088 Box of Bricks(平均值)
Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...
- HDOJ 1326 Box of Bricks(简单题)
Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...
- 591 - Box of Bricks
Box of Bricks Little Bob likes playing with his box of bricks. He puts the bricks one upon another ...
- Box of Bricks
Box of Bricks Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- 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(脑洞)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2088 Box of Bricks Time Limit: 1000/1000 MS (Java/Oth ...
- zoj 1251 Box of Bricks
Box of Bricks Time Limit: 2 Seconds Memory Limit: 65536 KB Little Bob likes playing with his bo ...
随机推荐
- WPF中添加Ribbon遇到的问题
很奇怪的说,当我新建WPF工程,添加RibbonControlsLibary.dll后会运行时会报错,System.Windows.Markup.XamlParseException.引发的异常信息为 ...
- PHP学习笔记(3) - 奇怪的class与autoload
PHP的class与其他语言有很多不同点.PHP允许很奇葩的在静态方法中调用实例方法,提供了关键字self和static用于访问类自身的静态成员.self永远是指当前的类,而static则可能会变成指 ...
- Linux学习笔记2
1.系统引导配置文件 # vi /boot/grub/grub.conf default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm. ...
- 两个不同于LR和jmeter的性能测试工具
LR图形界面,更利于使用 jmeter采用java,也能够扩展 相对于上两款工具,下面两款性能测试工具都采用了异步IO模型,扩展性都更强速度也更快 gatling:基于scala,速度相比更快性能压力 ...
- 【Git 】$ ./gradlew idea 构建一个idea的项目
Welcome to Git (version 1.9.5-preview20150319) Run 'git help git' to display the help index.Run 'git ...
- linux环境下验证码不显示的几种情况
linux环境下验证码不显示的几种情况 gd库扩展没有安装. 查看phpinfo(),看看有没有安装gd库 yum安装gd库或者phpize安装 安装完成后记得重启php-fpm bom头的原因 在生 ...
- Python 学习日志(一)
第一天: (一)安装Python3.3: (二)试运行: 1.在IDLE中输入:print("Hello,world"); //回车查看结果 2.使用"File" ...
- Tesseract——OCR图像识别 入门篇
Tesseract——OCR图像识别 入门篇 最近给了我一个任务,让我研究图像识别,从我们项目的screenshot中识别文字信息,so我开始了学习,与大家分享下. 我看到目前OCR技术有很多,最主要 ...
- python里面的几个编码函数
时不时的被编码折腾一下 >>> print urllib.quote('中国') %E4%B8%AD%E5%9B%BD >>> s = '%E4%B8%AD%E5% ...
- Firefly是什么?有什么特点?
原地址:http://bbs.gameres.com/forum.php?mod=viewthread&tid=219285 Firefly是免费.开源.稳定.快速扩展.能 “热更新”的分布式 ...