当前位置:网站首页>【学习笔记】阶段测试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) 。
注意别忘了乘阶乘 。
边栏推荐
- Brief introduction to revolutionary neural networks
- Sqllab 1-6 exercise
- Simple process of penetration test
- tidb-dm报警DM_sync_process_exists_with_error排查
- R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
- LeetCode_67(二进制求和)
- Don't be unconvinced. Mobile phone function upgrade is strong
- 2022 construction welder (special type of construction work) special operation certificate examination question bank and online simulation examination
- Oneconnect listed in Hong Kong: with a market value of HK $6.3 billion, ye Wangchun said that he was honest and trustworthy, and long-term success
- LeetCode_ 2 (add two numbers)
猜你喜欢
循环不变式
Tdengine biweekly selection of community issues | phase III
Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
Oneconnect listed in Hong Kong: with a market value of HK $6.3 billion, ye Wangchun said that he was honest and trustworthy, and long-term success
非技术部门,如何参与 DevOps?
Sharing the 12 most commonly used regular expressions can solve most of your problems
魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問
金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功
Recommendation number | what are interesting people looking at?
Postman简介、安装、入门使用方法详细攻略!
随机推荐
R语言ggplot2可视化:可视化折线图、使用theme函数中的legend.position参数自定义图例的位置
MySQL user-defined function ID number to age (supports 15 / 18 digit ID card)
Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
JS takes key and value from an array object to form a new object
矩阵链乘 - 动态规划实例
最长公共子序列 - 动态规划
Tdengine biweekly selection of community issues | phase III
Mysql database installation tutorial under Linux
别不服气。手机功能升级就是强
[buuctf.reverse] 152-154
Guofu hydrogen energy rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, and 360million yuan of accounts receivable exceed the revenue
一网打尽异步神器CompletableFuture
动态规划
01 、Solr7.3.1 在Win10平台下使用jetty的部署及配置
-Web direction attack and defense world
Mingfeng medical sprint technology innovation board: annual revenue of 350million yuan, proposed to raise 624million yuan
Sharing the 12 most commonly used regular expressions can solve most of your problems
R語言ggplot2可視化:可視化折線圖、使用theme函數中的legend.position參數自定義圖例的比特置
最简单不用证书也可以多开功能的方式
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting