# bzoj4300 绝世好题

3
1 2 3

2

## HINT

n<=100000,ai<=2*10^9

 1 //It is made by wfj_2048~
2 #include <algorithm>
3 #include <iostream>
4 #include <complex>
5 #include <cstring>
6 #include <cstdlib>
7 #include <cstdio>
8 #include <vector>
9 #include <cmath>
10 #include <queue>
11 #include <stack>
12 #include <map>
13 #include <set>
14 #define inf (1<<30)
15 #define N (100010)
16 #define il inline
17 #define RG register
18 #define ll long long
19
20 using namespace std;
21
22 int f[35],a[N],n,res,ans;
23
24 il int gi(){
25     RG int x=0,q=1; RG char ch=getchar(); while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
26     if (ch=='-') q=-1,ch=getchar(); while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar(); return q*x;
27 }
28
29 il void work(){
30     n=gi(); for (RG int i=1;i<=n;++i) a[i]=gi();
31     for (RG int i=1;i<=n;++i){
32     res=0; for (RG int j=0;j<=30;++j) if (a[i]&(1<<j)) res=max(res,f[j]);
33     res++; for (RG int j=0;j<=30;++j) if (a[i]&(1<<j)) f[j]=res;
34     }
35     for (RG int i=0;i<=30;++i) ans=max(ans,f[i]);
36     printf("%d\n",ans); return;
37 }
38
39 int main(){
40     work();
41     return 0;
42 }

posted @ 2017-03-11 22:30  wfj_2048  阅读(138)  评论(0编辑  收藏  举报