Given an n-length sequence AI, the longest length of the AI's subsequence bi is satisfied with bi&bi-1!=0 (2<=i<=len). The
Input
file has a total of 2 rows. The
First line includes an integer n. The second line of the
includes n integers, and the first integer represents AI. The
output
outputs a single line of files. The
includes an integer that represents the longest length of the subsequence bi.
Sample Input
3
1 2 3
Sample Output
2
Hint
N<=100000,ai<=2*10^9
DP represents the current number of digits can be reached The maximum length. The
DP transfer decision condition is a[i]& (1<
#include <iostream> #include <cstdio> #include <cstring> #include <
Algorithm> using namespace std;
typedef long Long LL;
const int MAXN = 1000011;
int N,a[maxn],ans;
int f[31];
int main () {cin>>n;
for (int i=1;i<=n;i++) cin>>a[i];
int now;
for (int i=1;i<=n;i++) {now=0;
for (int j=0;j<=30;j++) if ((a[i]& (1<<j))!=0) Now=max (F[j],now);
now++;
for (int j=0;j<=30;j++) if (a[i]& (1<<j)!=0) F[j]=max (F[j],now);
} for (int i=0;i<=30;i++) Ans=max (Ans,f[i]);
printf ("%d\n", ans); }