CF1463F Max Correct Set
考虑证明一个答案必定为\((x + y)\)的循环节递归。
考虑到如果第二块比第一块答案大,则必定可以把第一块换为第二块增加答案。
且可以证明,如果\((x + y)\)是合法的,则整个序列合法。
那我们只要做出第一个循环节的dp,并考虑剩下的零散点的取值即可。
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
int n,x,y,m,t,f[2][1<<22],ans;
inline void cmax(int &x,int y){if(y>x)x=y;}
int main(){
scanf("%d%d%d",&n,&x,&y);
m = x + y , t = 1 << 22;
memset(f[0],0xcf,sizeof(f[0]));
f[0][0] = 0;
rep(i,1,m){
int op = i & 1;
memset(f[op],0xcf,sizeof(f[op]));
rep(j,0,t-1){
cmax(f[op][(t-1)&(j<<1)],f[op^1][j]);
if(1 & (j >> (x - 1)))continue;
if(1 & (j >> (y - 1)))continue;
cmax(f[op][1^((t-1)&(j<<1))],f[op^1][j]+n/m+(n%m>=i));
}
rep(j,0,t-1)cmax(ans,f[op][j]);
}
printf("%d\n",ans);
return 0;
}
CF1463F Max Correct Set的更多相关文章
- Codeforces Round #330 (Div. 2)D. Max and Bike 二分 物理
D. Max and Bike Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/probl ...
- Error Correct System(模拟)
Error Correct System Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- 3dsmax不同版本 pyside qt UI 设置max窗口为父窗口的方法
3dsmax不同版本 pyside qt widget 设置 max 窗口为父窗口的方法 前言: 3dsmax 在 2014 extension 之后开始集成 Python 和 PySide,但是在版 ...
- Codeforces Round #350 (Div. 2) E. Correct Bracket Sequence Editor 栈 链表
E. Correct Bracket Sequence Editor 题目连接: http://www.codeforces.com/contest/670/problem/E Description ...
- Rigging a Versatile Weapon Bone for 3ds Max
说明:先添加weapon到点的约束,位置,方向约束都调整好了后再建立点到手,hip的父子关系,注意这个顺序 加点的方法 点设置成box的方法: http://hewiki.heroengine.com ...
- Codeforces Round #330 (Div. 2) D. Max and Bike 二分
D. Max and Bike For months Maxim has been coming to work on his favorite bicycle. And quite recently ...
- Codeforces Round #350 (Div. 2) E. Correct Bracket Sequence Editor 线段树模拟
E. Correct Bracket Sequence Editor Recently Polycarp started to develop a text editor that works o ...
- 【31.93%】【codeforces 670E】Correct Bracket Sequence Editor
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Kafka副本管理—— 为何去掉replica.lag.max.messages参数
今天查看Kafka 0.10.0的官方文档,发现了这样一句话:Configuration parameter replica.lag.max.messages was removed. Partiti ...
随机推荐
- 5分钟让你掌握Vuex,深入浅出
5分钟让你掌握Vuex,深入浅出 一.什么是Vuex? 概念:Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预 ...
- BUAA_2020_软件工程_个人博客作业
项目 内容 这个作业属于哪个课程 2020春季计算机学院软件工程(罗杰 任健) 这个作业的要求在哪里 个人博客作业 我在这个课程的目标是 了解软件工程的技术,掌握工程化开发的能力 这个作业在哪个具体方 ...
- Vue报错 type check failed for prop “xxx“. Expected String with value “xx“,got Number with value ‘xx‘
vue报错 [Vue warn]: Invalid prop: type check failed for prop "name". Expected String with ...
- elf文件--基于《ctf竞赛权威指南pwn篇》
1.ELF概念: ELF(Executable and Linkable Format),即"可执行可链接格式",最初由UNIX系统实验室作为应用程序二进制接口(Applicati ...
- 方阵里面的dp
打了一场luogu的信心赛,惊讶地发现我不会T2,感觉像这样在矩阵里面的dp看起来很套路的样子,但是仔细想想还是有很多需要注意的细节. 又想到之前貌似也考过一些类似的题目 然而我并没有改 ,于是打算补 ...
- stm32f103系列引脚定义-功能图
器件功能和配置(STM32F103xx增强型) STM32F103xx增强型模块框架图 STM32F103xx增强型VFQFPN36管脚图 STM32F103xx增强型LQFP100管脚图 STM32 ...
- 单片机STM32的5个时钟源知识
众所周知STM32有5个时钟源HSI.HSE.LSI.LSE.PLL,其实他只有四个,因为从上图中可以看到PLL都是由HSI或HSE提供的. 其中,高速时钟(HSE和HSI)提供给芯片主体的主时钟.低 ...
- Python pylint requires Python '>=3.4.*' but the running Python is 2.7.12
用pylint 1.9.x 安装 pip install pylint==1.9.3. 或者换源 pip install -i https://pypi.tuna.tsinghua.edu.cn/si ...
- CSS学习笔记:浮动属性
目录 一.浮动流是什么 二.通过代码实例了解浮动特点 1. 搭建测试框架 2. 添加浮动 3. 浮动元素的排布 4. 给行内元素添加浮动效果 5. 子元素浮动后对父元素的影响 5.1 在父元素中添加o ...
- google浏览器设置检查元素显示框位置