当前位置:网站首页>【学习笔记】阶段测试1
【学习笔记】阶段测试1
2022-07-05 14:10:00 【仰望星空的蚂蚁】
Menci 的序列
二进制 + 构造 + 贪心
第一眼是 dp 。想了 1.5h ,想不出来状态。
我会乱搞 !乱搞 80pts 。
首先把原序列改造一下。注意到 1000=010
这样构造后连续的 + 不超过 2 个
然后我们从高往低位贪心 。
显然是要用最少的 + 来构造。
因此最高位尽量不进位 。
不难想到贪心方案:从左往右遍历连续的 + 段,对于每一段连续的 + 只取一个,每一段连续的 * 也只取一个,这样前缀一定是 1111…
如果遇到后缀 * 不足的情况,那么这一段 * 的个数一定 >=2 ,足以隔断后面的选择对前面的影响(换句话说不可能进位了),那么我们只需让后面的 + 对答案贡献尽可能大 。
可以用两个二进制数相加来理解 。
你要问这个贪心怎么想到的,我也不知道 ,可能是感觉吧。
排序
膜拜 idsy …
这题第一感暴搜。
当然这题如果只能暴搜就太没意思了。
比如 Limak and Shooting Points 堪称搜索神题 。
其实正解挺显然啊 。
考虑 <=i 的操作都用了,那么对于长度为 2 i − 1 2^{i-1} 2i−1 的块内部顺序已定,毋宁看作一个整体 。
如果每一段都合法,则不执行操作;如果有一段不合法,则交换前后;如果有两段不合法,则分类讨论,最多有 2 2 2 种交换方法 。
这样可能的情况 2 n 2^n 2n 种,总复杂度 O ( 4 n ) O(4^n) O(4n) 。
注意别忘了乘阶乘 。
边栏推荐
- LeetCode_ 3 (longest substring without repeated characters)
- R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
- 区间 - 左闭右开
- TiFlash 面向编译器的自动向量化加速
- poi设置列的数据格式(有效)
- VC development of non MFC program memory leak tracking code
- Laravel - view (new and output views)
- R語言ggplot2可視化:可視化折線圖、使用theme函數中的legend.position參數自定義圖例的比特置
- 用“新”字来吸引好奇的人群
- Don't be unconvinced. Mobile phone function upgrade is strong
猜你喜欢

Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder

What category does the Internet of things application technology major belong to

分享 12 个最常用的正则表达式,能解决你大部分问题

治臻新能源冲刺科创板:年营收2.2亿 上汽创投是股东

Qingda KeYue rushes to the science and Innovation Board: the annual revenue is 200million, and it is proposed to raise 750million

神经网络物联网未来现状和趋势及看法

Getting started with rce

Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)

区间 - 左闭右开

金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功
随机推荐
mysql 自定义函数 身份证号转年龄(支持15/18位身份证)
LeetCode_67(二进制求和)
What is the future development trend of neural network Internet of things
做自媒体视频二次剪辑,怎样剪辑不算侵权
3W principle [easy to understand]
2022 construction welder (special type of construction work) special operation certificate examination question bank and online simulation examination
区间 - 左闭右开
LeetCode_2(两数相加)
01 、Solr7.3.1 在Win10平台下使用jetty的部署及配置
R語言ggplot2可視化:可視化折線圖、使用theme函數中的legend.position參數自定義圖例的比特置
C - Divisors of the Divisors of An Integer Gym - 102040C
怎么叫一手一机的功能方式
一网打尽异步神器CompletableFuture
明峰医疗冲刺科创板:年营收3.5亿元 拟募资6.24亿
OSI and tcp/ip protocol cluster
Assembly language
Enjoy what you want. Zhichuang future
如何深入理解“有限状态机”的设计思想?
The forked VM terminated without saying properly goodbye
Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
