• UVA 10066 The Twin Towers (LCS)


    The Twin Towers

    LCS水题,就是题读的时候有点费劲。   我英语是渣渣- -!

     1 #include <map>
     2 #include <queue>
     3 #include <stack>
     4 #include <math.h>
     5 #include <stdio.h>
     6 #include <string.h>
     7 #include <iostream>
     8 #include <algorithm>
     9 #define LL long long
    10 using namespace std;
    11 
    12 void run()
    13 {
    14     int n, m;
    15     int dp[110][110];
    16     int a[110], b[110];
    17     int cnt = 0;
    18     while(~scanf("%d%d", &n, &m))
    19     {
    20         cnt++;
    21         if(!n && !m)
    22             break;
    23         for(int i = 1; i <= n; i++)
    24             scanf("%d", &a[i]);
    25         for(int j = 1; j <= m; j++)
    26             scanf("%d", &b[j]);
    27         memset(dp, 0, sizeof(dp));
    28         for(int i = 1; i <= n; i++)
    29         {
    30             for(int j = 1; j <= m; j++)
    31             {
    32                 if(a[i] == b[j])
    33                     dp[i][j] = dp[i-1][j-1]+1;
    34                 else
    35                     dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    36             }
    37         }
    38         printf("Twin Towers #%d
    ", cnt);
    39         printf("Number of Tiles : %d
    
    ", dp[n][m]);
    40     }
    41 }
    42 
    43 int main(void)
    44 {
    45     run();
    46 
    47     return 0;
    48 }
    The Twin Towers
  • 相关阅读:
    python分析log
    单词长度统计,字符数量统计直方图
    单词计数
    字符替换
    HP Mobile Center 1.01 Related System Requirements
    字符统计
    文件复制
    C语言,不是从hello world开始
    最近
    echarts Map(地图) 不同颜色区块显示
  • 原文地址:https://www.cnblogs.com/Silence-AC/p/3409837.html
Copyright © 2020-2023  润新知