UVa 10192 Vacation:dp&lcs

Source: Internet
Author: User
Tags cas strlen time limit

10192-vacation

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_ problem&problem=1133

Water.

Complete code:

/*0.019s*/
    
#include <bits/stdc++.h>  
using namespace std;  
    
Char a[105], b[105];  
int dp[105][105];  
    
int main ()  
{  
    int lena, LenB, I, j, cas = 0;  
    while (gets (a), a[0]!= ' # ')  
    {  
        gets (b);  
        Lena = strlen (a), LenB = strlen (b);  
        memset (DP, 0, sizeof (DP));  
        for (i = 0; i < Lena. ++i) for  
            (j = 0; j < LenB; ++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 ("Case #%d:you can visit at most%d cities.\n", ++cas, Dp[lena][lenb]);  
    return 0;  
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.