time limit: 1 sec
memory limit: 128 mb
submit: 2197
solved: 1175 [
submit][
status][
discuss]
給定乙個長度為n的數列ai,求ai的子串行bi的最長長度,滿足bi&bi-1!=0(2<=i<=len)。
輸入檔案共2行。
第一行包括乙個整數n。
第二行包括n個整數,第i個整數表示ai。
輸出檔案共一行。
包括乙個整數,表示子串行bi的最長長度。 3
1 2 3
2n<=100000,ai<=2*10^9
by oxer [
submit][
status][
discuss]
home
back
這道題是絕世好題.
實際上是絕世水題. f[i]表示第i位上包含1的最長序列. log查詢, log更新.
#include#includeusing namespace std;
int n, mx, a[100005], f[100005], pw[31];
int main()
mx = 0;
for(int i = 0; i <= 30; ++i) mx = max(mx, f[i]);
printf("%d\n", mx);
}
BZOJ 4300 絕世好題 dp
description now give you a number sequence ai,you need to calculate the longest length of subsequence bi,meet the requirements of bi bi 1 is not equal...
BZOJ4300絕世好題(DP)
description 給定乙個長度為n的數列ai,求ai的子串行bi的最長長度,滿足bi bi 1 0 2 i len input 輸入檔案共2行。第一行包括乙個整數n。第二行包括n個整數,第i個整數表示ai。output 輸出檔案共一行。包括乙個整數,表示子串行bi的最長長度。sample in...
BZOJ 4300 絕世好題 dp
dp i 表示二進位制的第i位為1時的最大值,然後從左到右dp include include include using namespace std define b i 1 i const int maxn 100009 const int n 31 int dp 40 n int main p...