《ACM 书中题目》 k
来源:互联网 发布:mac视频导入iphone 编辑:程序博客网 时间:2024/06/03 02:14
题目
Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height.
Look, I've built a wall!'', he tells his older sister Alice.
Nah, you should make all stacks the same height. Then you would have a real wall.”, she retorts. After a little con- sideration, Bob sees that she is right. So he sets out to rearrange the bricks, one by one, such that all stacks are the same height afterwards. But since Bob is lazy he wants to do this with the minimum number of bricks moved. Can you help?理解
求出序列的平均数,超出平均数的部分就是要移动的块数AC代码
#include<iostream>using namespace std;int main(){ int i,j,k,l,sum=0,mv; int a[55],b[55]; for(j=1;cin>>l&&l!=0;j++) { sum=0; mv=0; for(i=0;i<l;i++) { cin>>a[i]; sum+=a[i]; } sum/=l; for(i=0;i<l;i++) { if((a[i]-sum)>0) mv+=(a[i]-sum); } cout<<"Set #"<<j<<endl<<"The minimum number of moves is "<<mv<<".\n"<<endl; }}
- 总结
刚开始两遍代码全部Presentation Error.
后来发现题目最后一句写着:Output a blank line after each set.
读题不够细致,主要还是对英文题目不太适应。
0 0
- ACM书中题目 K
- 《ACM 书中题目》 k
- 《ACM程序设计》书中题目―K
- 《ACM程序设计》书中题目 K
- 《ACM程序设计》书中题目--problem k
- acm书中题目 k-11
- ACM书中题目——K
- 《ACM程序设计》书中题目K-11
- 《ACM程序设计》书中题目 K
- 《ACM程序设计》书中题目 K
- acm程序设计书中题目k
- 《ACM程序设计》书中题目 K-11 build a wall
- 《ACM程序设计》书中题目K 第十一题 堆墙
- ACM程序设计书中题目--k (移动砖块)
- 关于acm程序设计书中题目 #J #K #L
- ACM书中的题目 k-11
- 《ACM程序设计》书中题目K(爱搭积木的小鲍勃)
- ACM书中题目 O
- Android关闭输入软键盘无效的问题
- Python爬虫豆瓣读书评分9分以上榜单
- nginx开发从入门到精通 http://tengine.taobao.org/book/
- 字母图形
- 浅析IEnumerable 和 IQueryable
- 《ACM 书中题目》 k
- String
- SCU 4489 misaka and last order(暴力枚举)
- 自动化测试数据驱动之xml文件读取
- linux Qt程序打包(linuxdeployqt工具的使用)
- OpenStack Heat 如何来实现和支持编排
- Python Selenium3 WebDriver Remote
- java collection framework
- JDBC