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 ...
随机推荐
- Amazon SES介绍 - SES发送邮件的过程
Amazon SES, 全称Amazon Simple Email Service,即Amazon简单邮件服务,它是Amazon提供的一款供开发人员或公司企业用来处理邮件相关业务的服务,也就是说, ...
- spring mvc:拦截器不拦截静态资源的三种处理方式
方案一.拦截器中增加针对静态资源不进行过滤(涉及spring-mvc.xml) <mvc:resources location="/" mapping="/**/* ...
- Android GridView 行间距过大(一页一行)
1. gridView.xml中 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&quo ...
- Django进阶Model篇002 - 模型类的定义
一.创建数据模型. 实例: 作者模型:一个作者有姓名. 作者详情模型:把作者的详情放到详情表,包含性别.email 地址和出生日期,作者详情模型与作者模型之间是一对一的关系(OneToOneField ...
- Codeforces Round #448 (Div. 2)C. Square Subsets
可以用状压dp,也可以用线型基,但是状压dp没看台懂... 线型基的重要性质 性质一:最高位1的位置互不相同 性质二:任意一个可以用这些向量组合出的向量x,组合方式唯一 性质三:线性基的任意一个子集异 ...
- poj3683 2 -sat输出路径
tarjan缩点,拓扑排序染色输出(貌似挑战上面没有拓扑啊,而且这样写还过了= =) 主要是找s,t,d,三者之间的关系,找出合取范式这题就很容易了 #include<map> #incl ...
- 【scala】构造器
和Java或C++一样,Scala可以有任意多的构造器. 不过Scala类有一个构造器比其他所有构造器都更为重要,它就是主构造器. 除了主构造器之外,类还可以有任意多的辅助构造器. 主构造器 在Sca ...
- 八大排序算法的java实现
有时间再贴算法分析图 JDK7的Collections.sort()的算法是TimSort, 适应性的归并排序, 比较晦涩难懂, 这里没有实现 public class mySort { // 冒泡排 ...
- C#学习历程(一)[基础概念]
#小摘要 >> boolean和bool差不多是一个东西,但是bool是一个基本值的类型,boolean则是对象(java与javascript中有用). Bool是Boolean的别名. ...
- Go语言的序列化与反序列化(gob)
encoding/gob包实现了高效的序列化,特别是数据结构较复杂的,结构体.数组和切片都被支持. 实现代码如下://定义一个结构体type Student struct { Name string ...