1125 Chain the Ropes
题意:略。
思路:思考一下,最先拿去对折的绳子会参与之后的每次对折,而对一条绳子而言,对折的次数越多剩下的就越短,因此,要让最终的结果尽可能长,应该先让较短的绳子先对折。
代码:
#include <cstdio>
#include <algorithm>
using namespace std;
;
int segment[maxn];
int main()
{
int n;
scanf("%d",&n);
;i<n;i++)
scanf("%d",&segment[i]);
sort(segment,segment+n);
];
;i<n;i++)
ans=(ans+segment[i])/;
printf("%d",ans);
;
}
1125 Chain the Ropes的更多相关文章
- 1125 Chain the Ropes (25 分)
1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rop ...
- PAT甲级 1125. Chain the Ropes (25)
1125. Chain the Ropes (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...
- PAT 1125 Chain the Ropes[一般]
1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rop ...
- PAT 1125 Chain the Ropes
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fo ...
- 1125. Chain the Ropes (25)
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fo ...
- PAT甲题题解-1125. Chain the Ropes (25)-贪心水题
贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #include <iostream> #include <cstdio> #include <algorithm&g ...
- PAT1125:Chain the Ropes
1125. Chain the Ropes (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...
- PAT_A1125#Chain the Ropes
Source: PAT A1125 Chain the Ropes (25 分) Description: Given some segments of rope, you are supposed ...
- A1125. Chain the Ropes
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fo ...
随机推荐
- Mybatis报错Cause: org.apache.ibatis.executor.ExecutorException: Executor was closed.
SqlSession被关闭了,检查是否使用了被关闭的SqlSession.
- jquery.js和jquery.min.js的区别介绍
1.区别:jquery官网提供2种jQuery的下载,一种是jquery.js另一种是jquery.min.js文件名不一定完全相同,但通常情况下:jquery.js是完整的未压缩的jQuery库,文 ...
- APP耗电量专项测试整理
Android: (使用batterystats) 方法: 手机自带的电量监控.GT 命令(5.0以上系统才可以): 1.下载historian.py脚本,下载地址:https://github.co ...
- python中sorted()函数的用法
一. 定义 sorted()函数对所有可迭代的对象进行排序操作 二. 语法 sorted(iterable [, key[, reverse]]]) iterable:可迭代对象 key:主要是用来进 ...
- 用 LoadLibraryExW 函数测试加载 dll (CSharp、Windows)
效果如下: $ llbtest "E:\Developer\emgucv-windesktop 3.3.0.2824\libs\x64" LoadLibraryExW PATH: ...
- 转 IOS动态类型isKindOfClass, isMemberOfClass
对象在运行时获取其类型的能力称为内省.内省可以有多种方法实现. 判断对象类型 -(BOOL) isKindOfClass: classObj判断是否是这个类或者这个类的子类的实例 -(BOOL) is ...
- UI-了解ISO
1. iOS学习路线: C语言:数据类型.流程控制.函数.指针.字符串.结构体.枚举.预处理: OC:面向对象.内存管理.分类.协议.Block.KVC/KVO.Foundation框架: iOS基础 ...
- Epoll 实例
服务端调试: [test@cs2 epoll]$ g++ epoll_server.cpp -o epoll_server -lpthread [test@cs2 epoll]$ ./epoll_se ...
- oracle重建undo表空间
create undo tablespace UNDOTBS2 datafile 'D:\oracle\product\10.2.0\oradata\ttonline\UNDOTBS02.DBF' s ...
- 演示使用Metasploit入侵Android
文本演示怎么使用Kali Linux入侵Android手机. Kali Linux IP地址:192.168.0.112:接收连接的端口:443. 同一局域网内android手机一部(android ...