zoukankan      html  css  js  c++  java
  • P4310 绝世好题

    这题貌似在某叶姓教练员的网站上做过。。

    好吧实际上正解是位运算的DP,不是很好做,但是!!骗分大法好啊,暴力枚举,每一次至多比当前处理出来的答案多1,如果已经有答案是当前答案+1,break跳出循环,就可以实实在在地卡过100啦

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<cmath>
     5 #include<queue>
     6 #include<stack>
     7 #include<deque>
     8 #include<algorithm>
     9 #define ll long long
    10 using namespace std;
    11 const int oo=0x3f3f3f3f;
    12 const int N=100005;
    13 
    14 int n,maxn=1;
    15 int a[N],f[N];
    16 
    17 int Min(int a,int b){return a<b?a:b;}
    18 int Max(int a,int b){return a>b?a:b;}
    19 int Abs(int a){return a>0?a:-a;}
    20 
    21 int get(){
    22     char zy=getchar();
    23     int z=1,y=0;
    24     while(zy>'9'||zy<'0'){
    25         if(zy=='-') z=-1;
    26         zy=getchar();
    27     }
    28     while(zy>='0'&&zy<='9'){
    29         y=(y<<1)+(y<<3)+zy-'0';
    30         zy=getchar();
    31     }
    32     return z*y;
    33 }
    34 
    35 int main(){
    36     n=get();
    37     for(int i=1;i<=n;i++){
    38         a[i]=get();
    39         f[i]=1;
    40     }
    41     for(int i=2;i<=n;i++){
    42         for(int j=i-1;j>=1;j--){
    43             if(f[i]>maxn) break;
    44             if(a[i]&a[j]){
    45                 f[i]=Max(f[i],f[j]+1);
    46             }
    47         }
    48         maxn=Max(maxn,f[i]);
    49     }
    50     printf("%d
    ",maxn);
    51     return 0;
    52 }
  • 相关阅读:
    Git学习笔记(一)
    sql复制表结构及复制表数据
    C#连接Oracle数据库查询数据
    ExcelHelper.cs
    MongoHelper.cs
    Accesshelper.cs
    Android_布局属性大全
    [WinForm]Dundas Chart控件学习(附源码)
    [Android]Adb connection Error:远程主机强迫关闭了一个现有的连接
    html to openxml
  • 原文地址:https://www.cnblogs.com/hahaha2124652975/p/11644835.html
Copyright © 2011-2022 走看看