Problem - 4476

  题意是,给出若干绳子,对同一根绳子只能切割一次,求出最多能获得多少长度相同的绳子。

  代码中,s是最大切割长度,而当前切割长度为t/2.

代码如下:

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio> using namespace std; const int N = ;
int cnt[N]; int main() {
int T, n;
cin >> T;
while (T-- && cin >> n) {
memset(cnt, , sizeof(cnt));
for (int i = , x; i < n; i++) {
scanf("%d", &x);
cnt[x]++;
}
int s = , t = , mx = ;
while (s < N) {
while (t < N && t <= (s << )) {
mx = max(mx, cnt[t] + n);
t++;
}
n -= cnt[s++];
}
cout << mx << endl;
}
return ;
}

——written by Lyon

hdu 4476 Cut the rope (2-pointer && simulation)的更多相关文章

  1. Cut the rope

    http://acm.nyist.net/JudgeOnline/problem.php?pid=651 描述We have a rope whose length is L. We will cut ...

  2. HDU 4762 Cut the Cake(公式)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  3. HDU 4655 Cut Pieces(数学分析题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4655 题意:给出n个石子,第i个石子可以染ai种颜色.对于每种颜色,比如颜色1221,我们称有3段.连 ...

  4. hdu 4655 Cut Pieces 找规律

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4655 题意:给你一组整数,代表每个木块所能涂成的颜色种数(编号1~ai),相邻的两块所能涂成的颜色如果是一 ...

  5. HDU 4762 Cut the Cake

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:将n个草莓随机放在蛋糕上,草莓被看做是点,然后将蛋糕平均切成m份,求所有草莓在同一块蛋 ...

  6. hdu 4762 Cut the Cake概率公式

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率. ...

  7. 2013长春网赛1004 hdu 4762 Cut the Cake

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题意:有个蛋糕,切成m块,将n个草莓放在上面,问所有的草莓放在同一块蛋糕上面的概率是多少.2 & ...

  8. HDU 4762 Cut the Cake (2013长春网络赛1004题,公式题)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  9. HDU 4762 Cut the Cake(高精度)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

随机推荐

  1. dom4解析 XML

    Java XML解析工具 dom4j介绍及使用实例 Java XML解析工具 dom4j介绍及使用实例 dom4j介绍 dom4j的项目地址:http://sourceforge.net/projec ...

  2. 悠星网络基于阿里云分析型数据库PostgreSQL版的数据实践

    说到“大数据”,当下这个词很火,各行各业涉及到数据的,目前都在提大数据,提数据仓库,数据挖掘或者机器学习,但同时另外一个热门的名词也很火,那就是“云”.越来越多的企业都在搭建属于自己的云平台,也有一些 ...

  3. C++函数部分总结

    目录 为什么要使用函数 为什么要用函数重载 C++传参方式 特殊的函数--递归函数 为什么要使用函数 使用函数可以将一个比较复杂的程序系统的分为若干块简洁的模块,使程序更加清晰明了 比如,我们想要模拟 ...

  4. jstree设置checkbox单选

    jstree设置插件checkbox只允许单选 jstree version console.log($.jstree.version); 3.3.8 单选配置参数: $.jstree.default ...

  5. 最短路径问题 HDU - 3790 (Dijkstra算法 + 双重权值)

    参考:https://www.cnblogs.com/qiufeihai/archive/2012/03/15/2398455.html 最短路径问题 Time Limit: 2000/1000 MS ...

  6. Direct2D 第5篇 绘制图像

    原文:Direct2D 第5篇 绘制图像 我加载的图像是一张透明底PNG图像,背景使用渐变的绿色画刷 #include <windows.h> #include <d2d1.h> ...

  7. SimpleDateFormat 以及java8 - DateTimeFormatter

    https://www.cnblogs.com/zhisheng/p/9206758.html 在看的过程中有这么一条: [强制]SimpleDateFormat 是线程不安全的类,一般不要定义为 s ...

  8. placeholder颜色更改

    ::-webkit-input-placeholder { /* WebKit browsers */ color:#999; } :-moz-placeholder { /* Mozilla Fir ...

  9. 【机器学习PAI实战】—— 玩转人工智能之综述

    摘要: 基于人工智能火热的大背景下,通过阿里云的机器学习平台PAI在真实场景中的应用,详细阐述相关算法及使用方法,力求能够让读者读后能够马上动手利用PAI搭建属于自己的机器学习实用方案,真正利用PAI ...

  10. 足迹地图 搜索jvectormap

    https://blog.wangjunfeng.com/foot_print/