bzoj 4300绝世好题
呵呵呵呵
1 #include<bits/stdc++.h> 2 #define INF 0x7fffffff 3 #define LL long long 4 #define N 100005 5 using namespace std; 6 inline int ra() 7 { 8 int x=0,f=1; char ch=getchar(); 9 while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();} 10 while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();} 11 return x*f; 12 } 13 int mx[50]; 14 int main() 15 { 16 int n=ra(); 17 for (int i=1; i<=n; i++) 18 { 19 int x=ra(),orz=0; 20 for (int j=0; j<=31; j++) 21 if (x&(1<<j)) 22 orz=max(orz,mx[j]+1); 23 for (int j=0; j<=31; j++) 24 if (x&(1<<j)) 25 mx[j]=orz; 26 } 27 int ans=0; 28 for (int j=0; j<=31; j++) 29 ans=max(ans,mx[j]); 30 cout<<ans; 31 return 0; 32 }