FZU 1502 Letter Deletion
最长公共子序列。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
inline int read()
{
char c = getchar(); while(!isdigit(c)) c = getchar();
int x = ;
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
return x;
} const int maxn=;
char s[maxn],t[maxn];
int dp[maxn][maxn]; int main()
{
while(~scanf("%s%s",s,t))
{
memset(dp,,sizeof dp);
int lens=strlen(s),lent=strlen(t),ans=;
for(int i=;i<lens;i++)
{
for(int j=;j<lent;j++)
{
if(s[i]==t[j]) dp[i+][j+]=dp[i][j]+;
else dp[i+][j+]=max(dp[i][j+],dp[i+][j]);
ans=max(dp[i+][j+],ans);
}
}
printf("%d\n",ans);
}
return ;
}
FZU 1502 Letter Deletion的更多相关文章
- FZU 1502 Letter Deletion(DP)
Description You are given two words (each word consists of upper-case English letters). Try to delet ...
- Soj题目分类
-----------------------------最优化问题------------------------------------- ----------------------常规动态规划 ...
- FZU Problem 1853 Number Deletion
Problem 1853 Number Deletion Accept: 80 Submit: 239 Time Limit: 1000 mSec Memory Limit : 32768 ...
- FZU 2218 Simple String Problem(简单字符串问题)
Description 题目描述 Recently, you have found your interest in string theory. Here is an interesting que ...
- FZU 2215 Simple Polynomial Problem(简单多项式问题)
Description 题目描述 You are given an polynomial of x consisting of only addition marks, multiplication ...
- (KMP Next的运用) Period II -- fzu -- 1901
http://acm.fzu.edu.cn/problem.php?pid=1901 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=703 ...
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- FZU 2137 奇异字符串 后缀树组+RMQ
题目连接:http://acm.fzu.edu.cn/problem.php?pid=2137 题解: 枚举x位置,向左右延伸计算答案 如何计算答案:对字符串建立SA,那么对于想双延伸的长度L,假如有 ...
- FZU 1914 单调队列
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1914 题意: 给出一个数列,如果它的前i(1<=i<=n)项和都是正的,那么这个数列是正的,问这个 ...
随机推荐
- dpkg -P <pkg>
http://www.linuxquestions.org/questions/debian-26/how-do-i-get-rid-of-those-rc-packages-as-seen-in-d ...
- open("","r")与open("","rb")的效率区别
fd = open("C:\Users\william\Desktop\dup_file - Copy (3).txt","r")for i in fd: pr ...
- iPhone doesn’t support any of GongShangJ.app’s architectures. You can add iPhone’s armv7s architectu
iPhone doesn't support any of GongShangJ.app's architectures. You can add iPhone's armv7s architectu
- 关于IT实例教程
W3c:http://www.w3school.com.cn/ 易百:http://www.yiibai.com/ 菜鸟教程:http://www.runoob.com/
- wso2 CEP集成storm实验
1.三台机子:192.168.225.1(manager,nimbus), 192.168.225.2(worker,supervisor), 192.168.225.3(worker,supervi ...
- python_实现_斐波那契额函数
在学递归的时候,用递归实现了一个 下面是代码 def fib(n): if n >= 3: return fib(n-1)+fib(n-2) else: return 1 print(fib(6 ...
- 一个小时快速搭建微信小程序
「小程序」这个划时代的产品发布快一周了,互联网技术人都在摩拳擦掌,跃跃欲试.可是小程序目前还在内测,首批只发放了 200 个内测资格(泪流满面).本以为没有 AppID 这个月就与小程序无缘了,庆幸的 ...
- cocos2d-3.x 创建动画
1.多文件帧序列动画 TrademarkAnimation.h #ifndef __TRADEMARK_ANIMATION_H__ #define __TRADEMARK_ANIMATION_H__ ...
- sublime 3 增加php开发插件
1.PHP语法自动完成插件 https://github.com/erichard/SublimePHPCompanion 2.ThinkPHP自动完成插件 https://github.com/ya ...
- Activity的生命周期和启动模式
Activity的生命周期分析 典型情况下的生命周期.是指在用户参与的情况下,Activity所经过的生命周期的改变. 异常情况下的生命周期.是指Activity被系统回收或者由于当前设备的Confi ...