当前位置:网站首页>【学习笔记】阶段测试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) 。
注意别忘了乘阶乘 。
边栏推荐
- 关于Apache Mesos的一些想法
- R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
- 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?
- 分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
- Assembly language
- Laravel - view (new and output views)
- R language ggplot2 visualization: visual line graph, using legend in theme function The position parameter defines the position of the legend
- Sqllab 1-6 exercise
- 微服务项目部署后,无法访问静态资源,无法访问到上传到upload中的文件,解决办法
猜你喜欢

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

Qingda KeYue rushes to the science and Innovation Board: the annual revenue is 200million, and it is proposed to raise 750million

How to deeply understand the design idea of "finite state machine"?

Detailed explanation of IP address and preparation of DOS basic commands and batch processing

让秒杀狂欢更从容:大促背后的数据库(下篇)

魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问

Postman简介、安装、入门使用方法详细攻略!

Scenario based technology architecture process based on tidb - Theory

LeetCode_ 2 (add two numbers)

TiCDC 6.0原理之Sorter演进
随机推荐
What are the advantages and characteristics of SAS interface
金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功
R语言ggplot2可视化:使用ggplot2可视化散点图、使用labs参数自定义X轴的轴标签文本(customize X axis labels)
Laravel - model (new model and use model)
What category does the Internet of things application technology major belong to
The simplest way to open more functions without certificates
SSH免密码登录详解
Judge whether the variable is an array
Sharing the 12 most commonly used regular expressions can solve most of your problems
Mingfeng medical sprint technology innovation board: annual revenue of 350million yuan, proposed to raise 624million yuan
Enjoy what you want. Zhichuang future
LeetCode_2(两数相加)
神经网络物联网未来现状和趋势及看法
Hongmeng fourth training
动态规划
基于伯努利原理的速度监测芯片可用于天然气管道泄露检测
The IPO of Ruineng industry was terminated: the annual revenue was 447million and it was planned to raise 376million
What is the ranking of GF futures? Is it safe and reliable to open an account for GF futures online?
LeetCode_67(二进制求和)
Current situation, trend and view of neural network Internet of things in the future
