bzoj 4300: 绝世好题
4300: 绝世好题
Time Limit: 1 Sec Memory Limit: 128 MB
Description
Input
Output
Sample Input
1 2 3
Sample Output
HINT
n<=100000,ai<=2*10^9
Source
#include<cstdio>
#define N 100010
inline int max(int a,int b){return a>b?a:b;}
inline int read()
{
int tmp=;
char ch=getchar();
while(ch<''||ch>'') ch=getchar();
while(ch>=''&&ch<=''){tmp=tmp*+ch-'';ch=getchar();}
return tmp;
}
int t,n,a[N],f[],ans;
int main()
{
n=read();
for(int i=;i<n;i++)
{
t=read();
int tmp=;
for(int j=;j<;j++)
if(t&(<<j)) tmp=max(f[j]+,tmp);
for(int j=;j<;j++)
if(t&(<<j)) f[j]=tmp;
ans=max(ans,tmp);
}
printf("%d",ans);
}
bzoj 4300: 绝世好题的更多相关文章
- HYSBZ(BZOJ) 4300 绝世好题(位运算,递推)
HYSBZ(BZOJ) 4300 绝世好题(位运算,递推) Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<= ...
- BZOJ 4300: 绝世好题 动态规划
4300: 绝世好题 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4300 Description 给定一个长度为n的数列ai,求ai的 ...
- 【递推】BZOJ 4300:绝世好题
4300: 绝世好题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 564 Solved: 289[Submit][Status][Discuss] ...
- bzoj 4300: 绝世好题 dp
4300: 绝世好题 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php ...
- BZOJ 4300 绝世好题(位运算)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4300 [题目大意] 给出一个序列a,求一个子序列b,使得&和不为0 [题解] ...
- bzoj 4300 绝世好题——DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4300 考虑 dp[ i ] 能从哪些 j 转移过来,就是那些 a[ j ] & a[ ...
- bzoj 4300 绝世好题 —— 思路
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4300 记录一下 mx[j] 表示以第 j 位上是1的元素结尾的子序列长度最大值,转移即可. ...
- bzoj 4300: 绝世好题【dp】
设f[i][j]表示数列到i为止最后一项第j位为1的最大子序列长度,每次从i-1中1<<j&a[i]!=0的位+1转移来 然后i维是不需要的,答案直接在dp过程中去max即可 #i ...
- BZOJ 4300: 绝世好题 二进制
对于每一个数字拆位,然后维护一个大小为 30 左右的桶即可. code: #include <bits/stdc++.h> #define N 100006 #define setIO(s ...
随机推荐
- 第三十八章 springboot+docker(maven)
回顾上一章的整个部署过程: 使用"mvn install"进行打包jar 将jar移动到与Dockerfile文件相同的文件夹下 编写Dockerfile文件 使用"do ...
- Kindeditor为什么提交后获取不到值
LinkButton不是表单提交方式所以获取不到.如果用button submit提交方式就是form提交方式后台就能获取到值 取得编辑器的HTML内容.KindEditor的可视化操作在新创建的if ...
- 新手入门Java需要注意的问题
学习编程,虽然有老师教,但是更重要的事自学.这是很重要的. 现在互联网上面资源太多了,这也就有一个问题:怎么才能在一定时间内学习该知识,掌握该技能呢? 理论联系实践! 学以致用!! 网上的资源太多了, ...
- MVC5+EF6 简易版CMS(非接口) 第三章:数据存储和业务处理
目录 简易版CMS后台管理系统开发流程 MVC5+EF6 简易版CMS(非接口) 第一章:新建项目 MVC5+EF6 简易版CMS(非接口) 第二章:建数据模型 MVC5+EF6 简易版CMS(非接口 ...
- 让IE8支持HTML5及canvas功能!chart.js图表绘制工具库IE8上兼容方案
第一步,我们加上对html5的支持. <!--[if IE]> <script src="/public/html5.js" type="text/ja ...
- python profile
一.profile,cProfile 1. python -m cProfile myprogram.py python -m profile myprog.py2. 使用import profile ...
- iOS.ReactNative-4-react-native-command-line-tool
Command line tool: react-native 1. react-native 是一个命令行工具 1.1 react-native简介 运行以下命令: ls -lt `which re ...
- Verilog之基本算数运算
1.加减法 module addsub ( :] dataa, :] datab, input add_sub, // if this is 1, add; else subtract input c ...
- FreeBSD_11-系统管理——{Part_3-网络}
一.Network Servers DNS unbound/local_unbound # /etc/rc.conf local_unbound_enable="YES" # 测试 ...
- (Python)集合、集合的函数
本节我们将学习python的另一种数据类型:集合(set) 1.集合(set) 集合在Python中是一种没有重复元素,且无序的数据类型,且不能通过索引来引用集合中的元素 >>> b ...