HDU 2088 Box of Bricks
来源:互联网 发布:流程图 软件 编辑:程序博客网 时间:2024/05/20 11:51
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2088
有一排高度不同的砖块,求最少搬动多少块可以使这一排砖块的高度一样(给的数据一定满足可以一样高)
求出这个平均高度,然后大于这个高度的减去平均高度 求和即为所求。
代码如下:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <vector>#include <set>#include <map>#include <queue>#include <stack>using namespace std;/*freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);*/int xh[55];int main(){ int n,sum,i,a,min,aver,cc=0; while(cin>>n,n) { sum=min=0; for(i=0;i<n;i++) { scanf("%d",&xh[i]); sum+=xh[i]; } if(cc!=0) printf("\n"); aver=sum/n;//平均高度 for(i=0;i<n;i++) { if(xh[i]>aver)//大于平均高度的求和 min+=xh[i]-aver; } printf("%d\n",min); cc++; } return 520;}
- HDU 2088 Box of Bricks
- HDU 2088 Box of Bricks
- hdu 2088 Box of Bricks
- HDU#2088: Box of Bricks
- HDU 2088 Box of Bricks
- HDU - 2088 - Box of Bricks
- HDU Box of Bricks
- hdu 2088 Box of Bricks(water~)
- HDU—— 2088 Box of Bricks
- HDOJ(HDU) 2088 Box of Bricks(平均值)
- HDU ACM 11 2088 Box of Bricks
- Box of Bricks 2088
- 2088 Box of Bricks
- Box of Bricks 2088
- HDU 1326 Box of Bricks
- HDU 1326 Box of Bricks
- HDU 1326 Box of Bricks
- HDU 1326 Box of Bricks
- OpenLDAP
- fedora 16 启动进入init 3 模式
- android游戏开发框架libgdx的使用(三)--中文显示与汉字绘制
- div+css布局解析
- adb pull /data/local/tmp/sogoushurufa_adr
- HDU 2088 Box of Bricks
- ToolKit-autohotkey_study
- android游戏开发框架libgdx的使用(四)--舞台和演员
- poj 2267 From Dusk till Dawn or: Vladimir the Vampire
- OTG和普通usb连接线
- android内存优化心得
- android游戏开发框架libgdx的使用(五)--舞台和常用UI类
- linux centos 6 ftp 服务器设置
- 介绍一款数据库管理软件