当前位置:网站首页>【学习笔记】阶段测试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) 。
注意别忘了乘阶乘 。
边栏推荐
- Recommendation number | what are interesting people looking at?
- R language ggplot2 visualization: visual line graph, using legend in theme function The position parameter defines the position of the legend
- LeetCode_ 3 (longest substring without repeated characters)
- 3W principle [easy to understand]
- mysql 自定义函数 身份证号转年龄(支持15/18位身份证)
- How to introduce devsecops into enterprises?
- Sharing the 12 most commonly used regular expressions can solve most of your problems
- Financial one account Hong Kong listed: market value of 6.3 billion HK $Ye wangchun said to be Keeping true and true, long - term work
- R Language ggplot2 Visualization: visualize linegraph, using Legend in Theme function. Paramètre de position emplacement de la légende personnalisée
- Comparison of several distributed databases
猜你喜欢
如何深入理解“有限状态机”的设计思想?
软件测试人在深圳有哪些值得去的互联网公司【软件测试人员专供版】
Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module
如何将 DevSecOps 引入企业?
TiCDC 6.0原理之Sorter演进
Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
世界环境日 | 周大福用心服务推动减碳环保
魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问
分享 12 个最常用的正则表达式,能解决你大部分问题
Introduction, installation, introduction and detailed introduction to postman!
随机推荐
矩阵链乘 - 动态规划实例
不相交集
Laravel dompdf exports PDF, and the problem of Chinese garbled code is solved
2022 construction welder (special type of construction work) special operation certificate examination question bank and online simulation examination
Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
The forked VM terminated without saying properly goodbye
R language ggplot2 visual bar graph: visualize the bar graph through the two-color gradient color theme, and add label text for each bar (geom_text function)
TiCDC 6.0原理之Sorter演进
Discussion on memset assignment
Tdengine biweekly selection of community issues | phase III
OSI and tcp/ip protocol cluster
Google EventBus 使用详解
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
强联通分量
Scenario based technology architecture process based on tidb - Theory
upload (1-6)
最长公共子序列 - 动态规划
世界环境日 | 周大福用心服务推动减碳环保
PHP5下WSDL,SOAP调用实现过程
[buuctf.reverse] 152-154