• uva 10066 The Twin Towers


    lcs,答案输出后有一个空行……

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<algorithm>
    #include<iostream>
    using namespace std;
    
    int main()
    {
        int a[110],b[110],i,j,n1,n2,dp[110][110],cas=0;
        while(~scanf("%d%d",&n1,&n2)&&n1&&n2)
        {
            for(i=0;i<n1;i++) scanf("%d",&a[i]);
            for(i=0;i<n2;i++) scanf("%d",&b[i]);
            memset(dp,0,sizeof(dp));
            for(i=1;i<=n1;i++)
                for(j=1;j<=n2;j++)
            {
                if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            printf("Twin Towers #%d
    ",++cas);
            printf("Number of Tiles : %d
    
    ",dp[n1][n2]);
        }
        return 0;
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

  • 相关阅读:
    POJ 2486
    奇怪的电梯
    穿越泥地(mud)
    救援行动(save)
    As Fast As Possible
    Connecting Universities
    They Are Everywhere
    Cells Not Under Attack
    吃饭
    花店橱窗(flower)
  • 原文地址:https://www.cnblogs.com/xryz/p/4848074.html
Copyright © 2020-2023  润新知