POJ——1477 Box of Bricks
来源:互联网 发布:数据调研公司排名 编辑:程序博客网 时间:2024/06/06 01:29
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
65 2 4 1 7 50
Sample Output
Set #1The minimum number of moves is 5.
简单贪心问题
#include<stdio.h>#include<string.h>#include<ctype.h>#include<float.h>#include<math.h>#include<stdlib.h>#include<time.h>#include<iostream>#include<algorithm>#include<set>#include<string>#include<map>#include<vector>#include<numeric>#include<bitset>#include<queue>#include<stack>#define M(i,n,m) for(int i=n;i<m;i++)#define N(j,n,m) for(int j=n;j<m;j++)#define L(N,n) memset(N,n,sizeof(N))const int MAX=1<<30;const int MIN=-MAX;using namespace std;double PI=acos(-1);///用C输出int main(){ int n; int a[1000]; int num=0; while(~scanf("%d",&n)) { if(!n) break; memset(a,-0,sizeof(a)); int sum=0; for(int i=0; i<n; i++) { scanf("%d",&a[i]); sum+=a[i]; } sum=sum/n; int s=0; for(int i=0; i<n; i++) if(a[i]>sum) s+=a[i]-sum; printf("Set #%d\n",++num); printf("The minimum number of moves is %d.\n\n",s); } return 0;}
- POJ——1477 Box of Bricks
- poj 1477 Box of Bricks
- POJ 1477 Box of Bricks
- poj 1477 Box of Bricks
- POJ 1477:Box of Bricks
- POJ 1477 Box of Bricks G++
- 1477 Box of Bricks
- 1477:Box of Bricks
- 1477 Box of Bricks
- HDU—— 2088 Box of Bricks
- Box of Bricks ——平均数问题
- (贪心5.2.8)POJ 1477 Box of Bricks
- POJ 1477 && HDU 1326 Box of Bricks(水~)
- pku 1477 Box of Bricks
- PKU 1477 Box of Bricks
- Box of Bricks
- 591 - Box of Bricks
- HDOJ1326 Box of Bricks
- Project facet Java version 1.8 is not supported.
- Android UI系列-----EditText和AutoCompleteTextView
- i++还是++i
- 第一个ios小程序以及实现私有成员和私有属性
- Java Web开发实战经典 实战练习2.5
- POJ——1477 Box of Bricks
- data.table Way - Learning Note Part 2
- 键盘事件keydown、keypress、keyup随笔整理总结
- 请求转发和重定向的区别
- 【算法分析】排序算法:堆排序
- 素数筛选法的进一步升级
- 基于用户的协同过滤算法vs基于物品的协同过滤算法
- noip2010 接水问题 (模拟)
- MongoDB性能优化