当前位置:网站首页>【学习笔记】阶段测试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) 。
注意别忘了乘阶乘 。
边栏推荐
- Google eventbus usage details
- R language ggplot2 visual density map: Visual density map by group and custom configuration geom_ The alpha parameter in the density function sets the image transparency (to prevent multiple density c
- 矩阵链乘 - 动态规划实例
- Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
- Tdengine biweekly selection of community issues | phase III
- C语言中限定符的作用
- Use the word "new" to attract curious people
- 金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功
- R language ggplot2 visualization: gganimate package is based on Transition_ The time function creates dynamic scatter animation (GIF) and uses shadow_ Mark function adds static scatter diagram as anim
- Why do I support bat to dismantle "AI research institute"
猜你喜欢

Recommendation number | what are interesting people looking at?

金融壹賬通香港上市:市值63億港元 葉望春稱守正篤實,久久為功

金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功

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

瑞能实业IPO被终止:年营收4.47亿 曾拟募资3.76亿

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

魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問

tidb-dm报警DM_sync_process_exists_with_error排查

Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
![Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]](/img/c2/a5f5fe17a6bd1f6f9df828ddd224d6.png)
Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
随机推荐
Mysql database installation tutorial under Linux
LeetCode_ 2 (add two numbers)
Recommendation number | what are interesting people looking at?
Leetcode array question brushing notes
LeetCode_2(两数相加)
04_ Use of solrj7.3 of solr7.3
04_solr7.3之solrJ7.3的使用
03_Solr之dataimport
The forked VM terminated without saying properly goodbye
3W原则[通俗易懂]
Mingfeng medical sprint technology innovation board: annual revenue of 350million yuan, proposed to raise 624million yuan
世界环境日 | 周大福用心服务推动减碳环保
Google EventBus 使用详解
神经网络物联网未来现状和趋势及看法
魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问
为什么我认识的机械工程师都抱怨工资低?
基于伯努利原理的速度监测芯片可用于天然气管道泄露检测
LeetCode_ 67 (binary sum)
Implementation process of WSDL and soap calls under PHP5
最长公共子序列 - 动态规划
