HDU-1159-Common Subsequence
来源:互联网 发布:淘宝不能点击立即购买 编辑:程序博客网 时间:2024/05/16 10:27
#include <iostream>#include<stdio.h>#include<string.h>using namespace std;const int MAX = 1010;char s1[MAX], s2[MAX];int dp[MAX][MAX];int main(){ while(~scanf("%s%s", s1, s2)) { memset(dp, 0, sizeof(dp)); int l1 = strlen(s1), l2= strlen(s2); for(int i = 0;s1[i];++i) { for(int j = 0;s2[j];++j) { if(s1[i]==s2[j]) { if(i&&j)dp[i][j] = dp[i-1][j-1]+1; else dp[i][j] = 1; } else if(i&&j)dp[i][j]= max(dp[i-1][j], dp[i][j-1]); else if(!i&&j)dp[i][j]= dp[i][j-1]; else if(!i&&!j)dp[i][j] = 0; else dp[i][j] = dp[i-1][j]; } } printf("%d\n", dp[l1-1][l2-1]); } return 0;}
0 0
- hdu 1159 Common Subsequence
- HDU 1159 Common Subsequence
- HDU 1159 Common Subsequence
- hdu 1159 Common Subsequence
- HDU 1159 Common Subsequence
- HDU 1159 Common Subsequence
- hdu 1159 Common Subsequence
- hdu 1159 Common Subsequence
- hdu 1159 Common Subsequence
- Common Subsequence hdu 1159
- HDU 1159 Common Subsequence
- HDU 1159 Common Subsequence
- hdu 1159 Common Subsequence
- hdu 1159 Common Subsequence
- HDU 1159 Common Subsequence
- hdu 1159 Common Subsequence
- hdu 1159 Common Subsequence
- hdu 1159 Common Subsequence
- iOS开发------Apple Pay(PassKit.framework篇)
- 从按按钮什么也不做想到的
- 基于Express框架使用POST传递Form数据
- Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If
- PAT 1006
- HDU-1159-Common Subsequence
- Git
- IntelliJ IDEA/MyEclipse自动生成签名
- 说说JSON和JSONP,也许你会豁然开朗
- 使用中文的 Cookie. name 与 value 都使用 UTF-8 编码
- easyui----1
- 已阻止此发布者在你的计算机上运行软件
- Labyrinth
- Java实用类库相关地址