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 ...
随机推荐
- js 小复习2
1.数组 findIndex() indexOf() // findIndex()方法返回数组中满足提供的测试函数的第一个元素的索引.否则返回-1. function isBigEnough(ele ...
- OAuth2疑问解答
转自:http://bylijinnan.iteye.com/blog/2277548 OAuth2的学习,我也是从阮一峰老师的博客中开始的:http://www.ruanyifeng.com/blo ...
- Linux文件夹权限详解
- 第一个字符代表文件(-).目录(d),链接(l) - 其余字符每3个一组(rwx),读(r).写(w).执行(x) - 第一组rwx:文件所有者的权限是读.写和执行 - 第二组rw-:与文件所有者 ...
- 简单使用JDOM解析XML
原文:http://liuwentao.iteye.com/blog/59978 使用JDOM解析XML一.前言JDOM是Breet Mclaughlin和Jason Hunter两大Java高手的创 ...
- About GCC
GCC used to stand for the GNU C Compiler, but since the compiler supports several other languages as ...
- Freemarker Failed at: ${itm.creatTimeString?string("yyyy-MM... [in template
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545} p.p2 {margin: ...
- ROS机器人星火计划公开课总结
非常荣幸参加了两次星火计划公开课(上海站), 感谢NXROBO.EXBOT以及所有支持ROS机器人星火计划的小伙伴们. ----废话开始,与课程总结无关,可跳过---- 在国内20多年的求学生涯以及2 ...
- MpVue开发之框架的搭建
npm install --global vue-cli vue脚手架 vue init mpvue/mpvue-quickstart my-project 创建一个基于mpvue-quickst ...
- LINUX系统yum安装SVN服务及其配置
待: http://oplinux.com/app/svn/linux-yum-install-svn.html //基础设置及流程 http://files.cnblogs.com/logon/s ...
- 【python】socket
UDP udp_server.py from datetime import datetime import socket server_address = ('localhost', 6789) m ...