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 ...
随机推荐
- JSP报错01
ZC: 创建一个JSP之后,就报如下错误. 1.错误: 1.1. 2.处理: Exlipse for JEE --> Project Explorer 中选择项目 --> 右击项目名 -- ...
- 基础的JavaScript函数
基础的JavaScript函数 1.首字母大写 2.去除数组重复项 3.数组的排序 4.闭包 1. 把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字(使用JavaScript的map函 ...
- Django进阶Model篇004 - ORM常用操作
一.增加 create和save方法 实例: 1.增加一条作者记录 >>> from hello.models import * >>> Author.object ...
- pip使用国内镜像解决安装超时
刚刚用pip install pipenv时,发现抛出一个超时的问题 这是从files.pythonhosted.org去下载的,国内的网访问时慢的出奇,然后就会出现超时的情况.这时候,可以使用国内镜 ...
- 51nod 1270 dp
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1270 简单的线性dp,最近狂刷水题真的是...药丸 差值最大得话要么是峰 ...
- [转载]Java动态生成word文档(图文并茂)
很多情况下,软件开发者需要从数据库读取数据,然后将数据动态填充到手工预先准备好的Word模板文档里,这对于大批量生成拥有相同格式排版的正式文件非常有用,这个功能应用PageOffice的基本动态填充功 ...
- windows server 2016 docker 之创建使用虚拟交换机
windows server 2016 Create a virtual switch for Hyper-V virtual machines 操作步骤: 服务器只有一块网卡连接了网络 尝试1: h ...
- LeetCode OJ:Valid Anagram(有效字谜问题)
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = &q ...
- webpack 使用中的问题
用gulp-watch代替watch webpack打包体积分析器 集合
- prefixfree.min.js 的用途
简单而言,这东西就是自动加前缀的,在link中,或是style中,或是dom元素的style中书写CSS3 code,或是jQuery .css()方法此脚本会自动补上需要的前缀,让响应的浏览器支持该 ...