zoukankan      html  css  js  c++  java
  • bzoj 3997: [TJOI2015]组合数学

    最长反链???什么鬼。。(今天真是sb,扒了一天题解,,)

    (自己画图看了一下,感觉答案适合从右上到左下那个对角线有点py交易,,然后想了一下,好难写,就开心扒题解了。。)

     1 #include <bits/stdc++.h>
     2 #define LL long long
     3 #define lowbit(x) x&(-x)
     4 #define inf 0x3f3f3f3f
     5 #define eps 1e-5
     6 #define N 1005
     7 using namespace std;
     8 inline int ra()
     9 {
    10     int x=0,f=1; char ch=getchar();
    11     while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
    12     while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    13     return x*f;
    14 }
    15 int n,m;
    16 int a[N][N],f[N][N];
    17 int main()
    18 {
    19     int T=ra();
    20     while (T--)
    21     {
    22         n=ra(); m=ra();
    23         for (int i=1; i<=n; i++)
    24             for (int j=1; j<=m; j++)
    25                 a[i][j]=ra();
    26         for (int i=1; i<=n; i++)
    27             for (int j=m; j>=1; j--)
    28                 f[i][j]=max(f[i-1][j+1]+a[i][j],max(f[i-1][j],f[i][j+1]));
    29         cout<<f[n][1]<<endl;
    30     }
    31     return  0;
    32 }
  • 相关阅读:
    ffplay代码播放pcm数据
    linux设备驱动
    i2c协议
    macos安裝Ruby
    mac安裝node.js
    Flutter-Wrap流式布局
    Flutter-CircleAvatar圆形和圆角图片
    Flutter-indexstack
    Flutter-Card卡片布局
    Flutter-去除ListView滑動波紋
  • 原文地址:https://www.cnblogs.com/ccd2333/p/6516914.html
Copyright © 2011-2022 走看看