BNU Box of Bricks
http://www.bnuoj.com/bnuoj/problem_show.php?pid=1596
#include<iostream>
#include<cstdio>
#include<algorithm> using namespace std; bool cmp(int a, int b)
{
return a<b;
} int main()
{
int n,i,k,sum,p;
int a[55];
k = 0;
while(scanf("%d",&n)&&n)
{
k++;
sum = 0;
for(i = 0; i < n; i++)
{
scanf("%d",&a[i]);
sum += a[i];
}
sum = sum/n;
sort(a,a+n,cmp);
p = 0;
for(i = 0; i < n; i++)
{
if(a[i] < sum)
{
p+=(sum-a[i]);
}
else
{
break;
}
}
printf("Set #%d\n",k);
printf("The minimum number of moves is %d.\n\n",p);
} return 0;
}
BNU 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 ...
- [POJ1477]Box of Bricks
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19503 Accepted: 7871 Description Litt ...
- 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 ...
随机推荐
- Canvas使用渐变之-线性渐变详解
在canvas里面,除了使用纯色,我们还能把填充和笔触样式设置为渐变色:线性渐变和径向渐变. 线性渐变 createLinearGradient(x0,y0,x1,y1) 返回 CanvasGrad ...
- Android的回调模拟
想要彻底理解安卓中用的回调,最好的办法是自己写一个类似的实现安卓中回调功能的实现方法. 我自己写了一个可以实现setOnClickListener回调的工程: 具体目录: 工程源码的具体地址:http ...
- Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: Connectio (andriod sdk manager) http://dl-ssl.google.com/android上不去解决方案
Fetching https://dl-ssl.google.com/android/repository/addons_list-2.xml Fetched Add-ons List succes ...
- Centos6 安全防护设置指南
参考博文: Centos 6.4安全防护设置指南 4.使用chattr命令给下列文件加上不可更改的属性 有效防止非法用户进行文件的修改. [root@localhost ~]# chattr +i / ...
- CGI PHP安装
./configure --with-php-config=/usr/local/php/bin/php-config--with-pdo-mysql=/usr/local/mysql PDO——MY ...
- DEDE里有个编码问题,不支持PHP5.4及以上版本!
公司新配置服务器,没有PHP环境,下载了个PHP5.5.25,配置完毕后,从另外一个服务器转移了一个DEDECMS做的网站,安装后,进入后台,恢复数据发现参数设置里的文本框,只要是中文信息,没有显示, ...
- java:字符串的“+”运算
今天在一篇博客里,意外的看到了一段关于java中对字符串的“+”运算的处理(博客原文:http://blog.csdn.net/yirentianran/article/details/2871417 ...
- 基于visual Studio2013解决C语言竞赛题之0302字符数出
题目 解决代码及点评 根据题目要求,只要根据用户输入的字母,判断字母之后,给出相应的输出即可 在以下代码中,f32函数实现了该功能,通过if条件判断语句 #include <stdio.h ...
- HDU1163【九余数定理】【水题】
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- [Swust 549]--变位词(vector水过)
Time limit(ms): 1000 Memory limit(kb): 65535 Description 输入N和一个要查找的字符串,以下有N个字符串,我们需要找出其中的所有待查找字符串的 ...