• PKU 1458 Common Subsequence(最长公共子序列,dp,简单)


    题目

     同:ZJU 1733,HDU 1159

    #include <stdio.h>
    #include <string.h>
    #include <algorithm>
    using namespace std;
    
    int dp[1010][1010];
    int main()
    {
        char a[1010], b[1010];    
        int la, lb;
        while(scanf("%s%s", a, b) != EOF)
        {
            memset(dp, 0, sizeof(dp));
            la = strlen(a), lb = strlen(b);
            for(int i = 0; i < la; i++)
            {
                for(int j = 0; j < lb; j++)
                {
                    if(a[i] == b[j])
                    {
                        dp[i+1][j+1] = dp[i][j] + 1;
                    }
                    else
                    {
                        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
                    }
                }
            }
            printf("%d
    ", dp[la][lb]);
        }
        return 0;
    }
    View Code
    一道又一道,好高兴!
  • 相关阅读:
    [UE4]Image
    [UE4]CheckBox
    [UE4]Button
    [UE4]Border
    [UE4]RichTextBlock
    [UE4]Text Box
    [UE4]字体材质
    [UE4]Retainer Box
    [UE4]Invalidation Box
    [UE4]Dynamic Entry Box
  • 原文地址:https://www.cnblogs.com/laiba2004/p/3631607.html
Copyright © 2020-2023  润新知