当前位置:网站首页>【学习笔记】阶段测试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) 。
注意别忘了乘阶乘 。
边栏推荐
- Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
- Sharing the 12 most commonly used regular expressions can solve most of your problems
- Webrtc learning (II)
- mysql 自定义函数 身份证号转年龄(支持15/18位身份证)
- 别不服气。手机功能升级就是强
- Use the word "new" to attract curious people
- 魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問
- LeetCode_ 67 (binary sum)
- 广发期货排名多少?网上办理广发期货开户安全可靠吗?
- Comparison of several distributed databases
猜你喜欢
Postman简介、安装、入门使用方法详细攻略!
Shen Ziyu, nouveau Président de Meizu: M. Huang Zhang, fondateur de Meizu, agira comme conseiller stratégique pour les produits scientifiques et technologiques de Meizu
-Web direction attack and defense world
Sharing the 12 most commonly used regular expressions can solve most of your problems
如何将 DevSecOps 引入企业?
Sorter evolution of ticdc 6.0 principle
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
Current situation, trend and view of neural network Internet of things in the future
ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)
What is the future development trend of neural network Internet of things
随机推荐
LeetCode_ 3 (longest substring without repeated characters)
享你所想。智创未来
Sqllab 1-6 exercise
强联通分量
R language uses boxplot function in native package (basic import package, graphics) to visualize box plot
金融壹賬通香港上市:市值63億港元 葉望春稱守正篤實,久久為功
OSI and tcp/ip protocol cluster
动态规划
Comparison of several distributed databases
Google EventBus 使用详解
怎么叫一手一机的功能方式
登录界面代码
How to call the function mode of one hand and one machine
01. Solr7.3.1 deployment and configuration of jetty under win10 platform
清大科越冲刺科创板:年营收2亿 拟募资7.5亿
Hongmeng fourth training
R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列
C - Divisors of the Divisors of An Integer Gym - 102040C
最长公共子序列 - 动态规划
LeetCode_ 2 (add two numbers)