PAT-A1125
来源:互联网 发布:linux tar命令出错 编辑:程序博客网 时间:2024/06/05 18:42
前几天去刷了PAT,趁热把答案记录下来供大家参考
这题完全是英语阅读题,题目读懂就能写
题意:两根绳子打结之后长度会变成原来绳长的一般,且向下取整
一维数组加sort函数搞定
#include<stdio.h>#include<algorithm>using namespace std;int rope[10010];int main(){int i, n, sum;scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&rope[i]);}sort(rope,rope+n);sum=rope[0];for(i=1;i<n;i++){sum=(sum+rope[i])/2;}printf("%d",sum);return 0;}
0 0
- PAT-A1125
- PAT a1125题解
- PAT A1125 Chain the Ropes
- PAT A1125. Chain the Ropes (25)(哈夫曼树)
- Tsinsen A1125 乘积最大
- A1125. 乘积最大 Tsinsen
- pat
- 【PAT】
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- pat
- 面试题集锦
- 【Java】知乎:学习 JAVA,有什么书籍推荐?学习的方法和过程是怎样的?
- Codeforce336D.Dima and Trap Graph(二分右端点+dfs验证)
- Merge Two Sorted Lists问题及解法
- 括号配对问题
- PAT-A1125
- springMVC 不扫描 controller 中的方法
- QtQuick 中的 qml 与 Qt 的 C++
- 软件测试定义
- 测试的知识
- javascript download excel file from JSON data
- 随笔二、oracle基本用法与语法
- BZOJ 1631: [Usaco2007 Feb]Cow Party spfa
- 软件测试(二)测试方法&测试任务