zoukankan      html  css  js  c++  java
  • [BZOJ 4300] 绝世好题

    [题目链接]

              https://www.lydsy.com/JudgeOnline/problem.php?id=4300

    [算法]

            记Fi表示二进制表示下第i位为1的最长序列

            可以通过枚举二进制的每一位进行转移

            时间复杂度 : O(NlogV)

    [代码]

             

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    
    int f[30];
    
    template <typename T> inline void chkmax(T &x,T y) { x = max(x,y); }
    template <typename T> inline void chkmin(T &x,T y) { x = min(x,y); }
    template <typename T> inline void read(T &x)
    {
        T f = 1; x = 0;
        char c = getchar();
        for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
        for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
        x *= f;
    }
    int main()
    {
            
            int n;
            read(n);
            for (int i = 1; i <= n; i++)
            {
                    int x;
                    read(x);
                    int value = 0;
                    for (int j = 0; j < 31; j++)
                            if (x & (1 << j)) chkmax(value , f[j] + 1);
                    for (int j = 0; j < 31; j++)
                            if (x & (1 << j)) chkmax(f[j] , value);
            }
            int ans = 0;
            for (int i = 0; i < 31; i++) chkmax(ans , f[i]);
            printf("%d
    " , ans);
            
            return 0;
        
    }
  • 相关阅读:
    var_threshold
    一些动态绑定数据代码
    直线与圆的拟合测量
    圆的拟合__测量圆心距
    halcon骨架与xld的区分
    dyn_threshold
    模板匹配加测量Demo
    ToString 格式
    S7-200 运动控制
    环形图片识别
  • 原文地址:https://www.cnblogs.com/evenbao/p/10146407.html
Copyright © 2011-2022 走看看