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 ...
随机推荐
- Hdu OJ 5113 Black And White (2014ACM/ICPC亚洲区北京站) (搜索)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5113 题目大意:有k种颜色的方块,每种颜色有ai个, 现在有n*m的矩阵, 问这k种颜色的方块能否使任 ...
- 前端开发必备! 20 个强大的 Sublime Text 插件
http://www.oschina.net/translate/20-powerful-sublimetext-plugins http://www.w3cplus.com/tools/emmet- ...
- 【随笔】vmstat性能监测
vmstat命令是最常见的Linux/Unix监控工具,可以展现给定时间间隔的服务器的状态值,包括服务器的CPU使用率,内存使用,虚拟内存交换情况,IO读写情况.相比top,vmstat可以看到整个机 ...
- poj 2551 Ones
本题的想法很简单,就是模拟手算乘法.不一样的是,需要控制输出的结果:每一位都是由1构成的整数. 代码如下: #include <iostream> using namespace std; ...
- [Notes] Reading Notes on [Adaptive Robot Control – mxautomation J. Braumann 2015]
Reading sources: 1.Johannes Braumann, Sigrid Brell-Cokcan, Adaptive Robot Control (ARC ) Note: buil ...
- delphi XE5下 andriod 广告图片的demo
试了一下,关于好几个广告界面,左右滚动的效果:用TabControl 加上定时器实现即可. 1.TTabControl外观 TTabControl的外观由属性TabPosition控制,可选项包括: ...
- centos 6.5 + php5.5.31 fastcgi (fpm) 编译安装
yum intsall zlib zlib-devel //gzip 压缩和解压 yum install openssl openssl-devel yum install libxml2 libxm ...
- Android性能优化方法(八)
Android SDK tools目录下提供一个观察布局的工具,层级观察器(Hierarchy Viewer).Hierarchy Viewer工具是一个非常好的布局优化工具,同时,你也可以通过它学习 ...
- Android之Inflate()方法用途
转自:http://blog.csdn.net/andypan1314/article/details/6715928 Inflate()作用就是将xml定义的一个布局找出来,但仅仅是找出来而且隐藏的 ...
- Digit Root ---- 余九定理
题目:hdu1013, hdu1163, 51nod1116. or dr(n) = (n-1)%9+1. 其中,n-1是为了将结果0-8匹配到1-9. Reference: [1] https:// ...