当前位置:网站首页>【学习笔记】阶段测试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) 。
注意别忘了乘阶乘 。
边栏推荐
- 神经网络物联网未来发展趋势怎么样
- 怎么叫一手一机的功能方式
- 用“新”字来吸引好奇的人群
- R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
- 矩阵链乘 - 动态规划实例
- 明峰医疗冲刺科创板:年营收3.5亿元 拟募资6.24亿
- Don't be unconvinced. Mobile phone function upgrade is strong
- 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
- 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)
- R language uses the polR function of mass package to build an ordered multi classification logistic regression model, and uses the coef function to obtain the log odds ratio corresponding to each vari
猜你喜欢

分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少

神经网络物联网未来发展趋势怎么样

无密码身份验证如何保障用户隐私安全?

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

为什么我认识的机械工程师都抱怨工资低?

明峰医疗冲刺科创板:年营收3.5亿元 拟募资6.24亿

What are the advantages and characteristics of SAS interface

ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)

如何将 DevSecOps 引入企业?

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
随机推荐
Sharing the 12 most commonly used regular expressions can solve most of your problems
Enjoy what you want. Zhichuang future
Why do I support bat to dismantle "AI research institute"
Detailed explanation of SSH password free login
矩阵链乘 - 动态规划实例
03_ Dataimport of Solr
TDengine 社区问题双周精选 | 第三期
R语言使用原生包(基础导入包、graphics)中的boxplot函数可视化箱图(box plot)
R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列
Discussion on memset assignment
怎么叫一手一机的功能方式
Tdengine biweekly selection of community issues | phase III
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
LeetCode_ 67 (binary sum)
区间 - 左闭右开
强联通分量
tidb-dm报警DM_sync_process_exists_with_error排查
IP packet header analysis and static routing
LeetCode_69(x 的平方根 )
无密码身份验证如何保障用户隐私安全?
