zoukankan      html  css  js  c++  java
  • bzoj 4300: 绝世好题

    4300: 绝世好题

    Time Limit: 1 Sec  Memory Limit: 128 MB

    Description

    给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len)。
     

    Input

    输入文件共2行。
    第一行包括一个整数n。
    第二行包括n个整数,第i个整数表示ai。
     

    Output

    输出文件共一行。
    包括一个整数,表示子序列bi的最长长度。
     

    Sample Input

    3
    1 2 3

    Sample Output

    2

    HINT

    n<=100000,ai<=2*10^9


    Source

    #include<cstdio>
    #define N 100010
    inline int max(int a,int b){return a>b?a:b;}
    inline int read()
    {
        int tmp=0;
        char ch=getchar();
        while(ch<'0'||ch>'9') ch=getchar();
        while(ch>='0'&&ch<='9'){tmp=tmp*10+ch-'0';ch=getchar();}
        return tmp;
    }
    int t,n,a[N],f[33],ans;
    int main()
    {
        n=read();
        for(int i=0;i<n;i++)
        {
            t=read();
            int tmp=0;
            for(int j=0;j<31;j++)
            if(t&(1<<j)) tmp=max(f[j]+1,tmp);
            for(int j=0;j<31;j++)
            if(t&(1<<j)) f[j]=tmp;
            ans=max(ans,tmp);
        }
        printf("%d",ans);
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    Django入门
    初识json
    回来了
    python学习
    JavaScript 中获取元素样式
    浏览器检测与特征检测
    DOM 节点的类型及判定
    浏览器的控制台工具
    .htaccess 配置文件的使用
    workLog:07001:补充0829 前
  • 原文地址:https://www.cnblogs.com/lkhll/p/6110815.html
Copyright © 2011-2022 走看看