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. dom元素分屏加载

    载入一个内容较多的页面的时候,如果不做任何处理,则会在一开始就把全部内容加载出来,影响了性能和体验,所以现在常用分屏加载的功能,就是dom内容出现在屏幕可视范围内的时候,再加载dom节点,起到优化的作 ...

  2. wordpress设置一个特定的页面作为首页

    首先在"页面"里新建一个页面,比如标题为"welcome"; 然后在设置里找到"阅读",首页显示调整为"一个静态页面", ...

  3. golang之结构体

    Go 语言使用结构体和结构体成员来描述真实世界的实体和实体对应的各种属性. Go语言通过用自定义的方式形成新的类型,结构体是类型中带有成员的复合类型. Go 语言中的类型可以被实例化,使用new或&a ...

  4. Django项目:CRM(客户关系管理系统)--13--05PerfectCRM实现King_admin注册功能获取内存02

    admin_class.model = modelself.registered_sites[app_name][model_name] = admin_class #注册APP #base_admi ...

  5. 复习解析嵌套json

    在网络上找的一些经典的例子复习使用 一,解析嵌套json字符串,一个json字符串中嵌套另一个json字符串 { "msg": { "resCode": &qu ...

  6. JS中浏览器兼容问题

    body的子节点IE 火狐 显示3个  其他显示7个 float浮动中的兼容 link 操作外联的兼容

  7. Leetcode717.1-bit and 2-bit Characters1比特与2比特字符

    有两种特殊字符.第一种字符可以用一比特0来表示.第二种字符可以用两比特(10 或 11)来表示. 现给一个由若干比特组成的字符串.问最后一个字符是否必定为一个一比特字符.给定的字符串总是由0结束. 示 ...

  8. Markdown 常用语法学习(stackedit)

    Welcome to StackEdit!{#welcome} ===================== Hello, I am your first Markdown document withi ...

  9. php框架tp3.2.3和js写的微信分享功能心得,分享的标题内容图片自定义

    https://blog.csdn.net/weixin_42231483/article/details/81585322 最近用PHP的tp3.2.3框架和js写的微信分享功能心得,分享的标题内容 ...

  10. gitlab 添加本地项目

    1.安装git    https://git-scm.com/downloads 2.新建工程 3.创建密钥 a.桌面右键 b.cd ~/.ssh/ 如果提示 “ No such file or di ...