DP (i) represents the maximum value of the binary I-bit 1 o'clock, then the DP from left to right
------------------------------------------------------------------------
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define B (i) (1 << (i))const int MAXN = 100009;const int n = +;int dp[40], N;int main () {memset (DP, 0, sizeof DP);scanf ("%d", &n);for (int i = 0; i < N; i++) {int t = 0, A;scanf ("%d", &a);For (int j = 0; J < N; j + +)if (b (j) & a) T = max (T, Dp[j]);t++;For (int j = 0; J < N; j + +)if (b (j) & A) dp[j] = max (dp[j], t);}printf ("%d\n", *max_element (DP, DP + +));return 0;}
------------------------------------------------------------------------
4300: Good title time limit: 1 Sec Memory Limit: MB
Submit: 274 Solved: 168
[Submit] [Status] [Discuss] Description 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).
Input file total 2 rows. The first line includes an integer n. The second line includes n integers, and the first integer represents AI.
Output file has a single row. Includes an integer that represents the longest length of the subsequence bi.
Sample Input3
1 2 3Sample Output2HINT
For 100% of data, 1<=n<=100000,ai<=10^9.
Source
by Oxer
Bzoj 4300: A great problem (DP)