zoukankan      html  css  js  c++  java
  • POJ 2192

     1 #include <iostream>
     2 #include <string>
     3 #define MAXN 500
     4 using namespace std;
     5 
     6 bool dp[MAXN][MAXN];
     7 
     8 int main()
     9 {
    10     //freopen("acm.acm","r",stdin);
    11     int test;
    12     string s_1;
    13     string s_2;
    14     string s_3;
    15     int i;
    16     int j;
    17     int k;
    18     int time = 0;
    19     cin>>test;
    20     while(test --)
    21     {
    22         cout<<"Data set "<<++ time<<": ";
    23         memset(dp,false,sizeof(dp));
    24         cin>>s_1>>s_2>>s_3;
    25         dp[0][0] = true;
    26         for(i = 0; i <= s_1.length(); ++ i)
    27         {
    28             for(j = 0; j <= s_2.length(); ++ j)
    29             {
    30                 if(i-1 >= 0 && dp[i-1][j] && s_1[i-1] == s_3[i+j-1])
    31                 {
    32             //        if()
    33                     {
    34                         dp[i][j] = true;
    35                     }
    36                 }    
    37                 if(j-1 >= 0 && dp[i][j-1] && s_2[j-1] == s_3[i+j-1])
    38                 {
    39                     //if()
    40                     {
    41                         dp[i][j] = true;
    42                     }
    43                 }
    44             }
    45         }
    46         if(dp[s_1.length()][s_2.length()])
    47         {
    48             cout<<"yes"<<endl;
    49         }
    50         else
    51         {
    52             cout<<"no"<<endl;
    53         }
    54     }
    55 }

    关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

    技术网站地址: vmfor.com

  • 相关阅读:
    mysql日常~gh-ost使用
    redis基础篇~哨兵
    zeppelin-0.6.0安装配置
    spark 好文链接
    spark API 介绍链接
    solr5.5 基于内置jetty配置 Ubuntu
    Gollum 安装笔记
    手机版测试
    win7 eclipse 调试storm
    (转)Storm UI 解释
  • 原文地址:https://www.cnblogs.com/gavinsp/p/4566697.html
Copyright © 2011-2022 走看看