description:

n a i a i b i l e n b i 给定一个长度为n的数列ai,求ai的子序列bi的最长长 度len,满足b_i naiaibilenbi a n d and and b i 1 ! = 0 ( 2 i l e n ) b_{i−1} != 0(2 ≤ i ≤ len) bi1!=0(2ilen)

n 1 0 5 n ≤ 10^5 n105

a i 1 0 9 a_i ≤ 10^9 ai109

solution:


code:

#include<cstdio>
#include<iostream>
using namespace std;
int dp[105];
int main()
{
	int n;
	scanf("%d",&n);
	int a;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		int k=1;
		for(int j=0;j<=30;j++)
		{
			if((1<<j)&a)
			{
				k=max(dp[j]+1,k);
			}
		}
		for(int j=0;j<=30;j++)
		{
			if((1<<j)&a)
			{
				dp[j]=max(dp[j],k);
			}
		}
		ans=max(ans,k);
	}
	printf("%d\n",ans);
	return 0;
	
}