BZOJ 4300 絕世好題 動態規劃

題目大意:給定一個序列a ,求一個子序列b 使得bi and bi10|b| 最大

傻逼題。

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define M 100100
using namespace std;
int n,ans;
int f[32];
int main()
{
    int i,j,x;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        int temp=0;
        for(j=0;j<=30;j++)
            if(x&(1<<j))
                temp=max(temp,f[j]+1);
        for(j=0;j<=30;j++)
            if(x&(1<<j))
                f[j]=temp;
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章