[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 ...
随机推荐
- 利用getComputedStyle方法获取元素css的属性值
在平时的工作中有时候会碰到需要获取元素当前样式的问题,查了一下可以用getComputedStyle这个方法来获取元素计算后的样式(有些我们在css里面没有写的,浏览器默认的样式也可以获得) getC ...
- 过滤部分错误信息,不输出到stderr
cmd 2>/tmp/stderr.log cat /tmp/stderr.log | grep -v “要过滤信息的关键字” >&2 rm /tmp/stderr.log
- mysql的错误:The server quit without updating PID file /usr/local/mysql/data/door.pid).
mysql错误解决: 先 参考:http://www.jb51.net/article/48625.htm 参考第四条: mysql在启动时没有指定配置文件时会使用/etc/my.cnf配置文件,请打 ...
- Android RelativeLayout 属性
// 相对于给定ID控件 android:layout_above 将该控件的底部置于给定ID的控件之上; android:layout_below 将该控件的底部置于给定ID的控件之下; andro ...
- java 对象 类 知识点 概览
第30集 面向对象,核心是对象,以对象来思考
- c/c++ 重载 数组 操作符[] operator[ is ambiguous, as 0 also mean a null pointer of const char* type.
// Note: //int x = a[0].GetInt(); // Error: operator[ is ambiguous, as 0 also mean a null pointer of ...
- easyui源码翻译1.32--TimeSpinner(时间微调)
前言 扩展自$.fn.spinner.defaults.使用$.fn.timespinner.defaults重写默认值对象.下载该插件翻译源码 时间微调组件的创建基于微调组件.它和数字微调类似,但是 ...
- ANDROID_MARS学习笔记_S01原始版_005_ProgressBar
一.代码 1.xml(1)main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLay ...
- springboot 配置多数据源
1.首先在创建应用对象时引入autoConfig package com; import org.springframework.boot.SpringApplication; import org. ...
- GetActiveView 返回 NULL 为 MDI 框架窗口
blog 在 MDI 应用程序中,MDI 主框架窗口(CMDIFrameWnd) 不具有与其相关联的视图.相反,每个单独的子窗口(CMDIChildWnd)具有与之关联的一个或多个视图.因此,对 MD ...