zoukankan      html  css  js  c++  java
  • 在博客园安家啦~LightOJ 1004 Monkey Banana Problem (简单DP)

    作为一个ACMer,今天在博客园也建立了自己的博客,距离开始在CSDN写博客大概11个月,许多大牛的博客在博客园,不能添加关注深感不便。

    同时,CSDN不能折叠代码,写起总结感觉十分不便,我在CSDN的博文也不少了,查找想要的总结性质的东西效率越来越低……

    我的CSDN博客地址:http://blog.csdn.net/whyorwhnt

    初步构想题解发在CSDN,这里就用来写总结吧。

    作为开通纪念,随手敲道DP水题凑数……

    #include <cstdio>
    #include <cstring>
    #define max(a,b) ((a)>(b)?(a):(b))
    
    #ifdef unix
    #define i64 long long
    #define LLD "%lld"
    #else
    #define i64 __int64
    #define LLD "%I64d"
    #endif
    
    i64 data[205][105];
    
    int main ()
    {
    #ifdef ONLINE_JUDGE
    #else
        freopen("read.txt","r",stdin);
    #endif
        int T;
        scanf("%d",&T);
        for (int Cas=1;Cas<=T;Cas++)
        {
            int n,i,j;
            scanf("%d",&n);
            memset(data,0,sizeof(data));
            for (i=1;i<=n;i++)
                for (j=1;j<=i;j++)
                    scanf(LLD,&data[i][j]);
            for (i=1;i<=n-1;i++)
                for (j=1;j<=n-i;j++)
                    scanf(LLD,&data[n+i][j]);
            for (i=2;i<=n;i++)
                for (j=1;j<=i;j++)
                    data[i][j]+=max(data[i-1][j-1],data[i-1][j]);
            for (i=1;i<=n-1;i++)
                for (j=1;j<=n-i;j++)
                    data[n+i][j]+=max(data[n+i-1][j],data[n+i-1][j+1]);
            printf("Case %d: ",Cas);
            printf(LLD,data[2*n-1][1]);
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    Django组件-cookie与session
    Js获取标签高度
    js动态添加事件
    div 显示与隐藏
    JS字符串截取
    网页事件
    js_event.keycode值大全
    DOS删除服务
    判断字符串的编码
    《把时间当作朋友》读书笔记(二)-- 困境
  • 原文地址:https://www.cnblogs.com/whyorwhnt/p/3411207.html
Copyright © 2011-2022 走看看