题意:略。

思路:思考一下,最先拿去对折的绳子会参与之后的每次对折,而对一条绳子而言,对折的次数越多剩下的就越短,因此,要让最终的结果尽可能长,应该先让较短的绳子先对折。

代码:

#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的更多相关文章

  1. 1125 Chain the Ropes (25 分)

    1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rop ...

  2. PAT甲级 1125. Chain the Ropes (25)

    1125. Chain the Ropes (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...

  3. PAT 1125 Chain the Ropes[一般]

    1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rop ...

  4. 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 ...

  5. 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 ...

  6. PAT甲题题解-1125. Chain the Ropes (25)-贪心水题

    贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #include <iostream> #include <cstdio> #include <algorithm&g ...

  7. PAT1125:Chain the Ropes

    1125. Chain the Ropes (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...

  8. PAT_A1125#Chain the Ropes

    Source: PAT A1125 Chain the Ropes (25 分) Description: Given some segments of rope, you are supposed ...

  9. A1125. Chain the Ropes

    Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fo ...

随机推荐

  1. python标准日志模块logging使用

    python的标准库里的日志系统从Python2.3开始支持.只要import logging这个模块即可使用.如果你想开发一个日志系统, 既要把日志输出到控制台, 还要写入日志文件,只要这样使用: ...

  2. ultraedit使用记录

    ultraedit使用记录 10:57:33 在日常的工作中,我经常用keil进行程序的编写等工作,不过在编写过程中Keil对中文的支持不是很好,容易发生问题:同事推荐我用ultraedit进行程序的 ...

  3. datagrid拖动列头更换排列顺序

    在做这个功能的时候在网上找了大量资料,发现都不适用,要不然就是代码太冗余,所以另起炉灶,自己封装了这个函数 下面是完整的代码: <!DOCTYPE html> <html> & ...

  4. 【sparkStreaming】kafka作为数据源的生产和消费

    1.建立生产者发送数据 (1)配置zookeeper属性信息props (2)通过 new KafkaProducer[KeyType,ValueType](props) 建立producer (3) ...

  5. spring定时器的定义

    1.0/5 * * * * ?表示多长时间: 每 5 秒执行一次 七个域从左到右依次是,秒,分,时,日,月,周几,年....最后一个可选.同样是七个域与当前时间匹配的时候则执行... n/m 表示从n ...

  6. std::hash实现太简单分布不匀

    std::hash实现太简单分布不匀(金庆的专栏 2017.5)#include <iostream>#include <functional>using namespace ...

  7. 微信小程序如何在使用wx.request使用cookie

    我主要是做asp.net mvc后端开发的,经常使用Jquery的ajax与后台的Web API进行数据交互. 最近公司要做一个小程序,要实现小程序与Web前端的通信,当然小程序是可以实现socket ...

  8. 旧书重温:0day2【10】第五章 堆溢出利用2

    好久没有发帖子啦!最近一直很忙!但是还是抽空学习啦下! 前段时间匆匆忙忙的把0day2上的堆溢出实验做啦! 可能当时太浮躁啦,很多细节没注意!结果:实验结果很不满意!所以就有啦这一篇!! 上一篇是发布 ...

  9. Gradle配置IDEA正常识别JPA Metamodel Generator动态生成的代码

    我们在使用JPA动态查询构建查询条件时,为了实现安全的类型检查,常常需要引用Hibernate JPA Metamodel Generator自动为我们生成静态元模型类. 而这些类由于编译时由Hibe ...

  10. c printf打印格式

    关于小数点位数的举例:  <pre lang="c" escaped="true">#include <stdio.h> /* 当fah ...