【LightOJ 1013】Love Calculator(LCS+DP)
2016-07-26 20:17
489 查看
Problem Description
Yes, you are developing a ‘Love calculator’. The software would be quite complex such that nobody could crack the exact behavior of the software.So, given two names your software will generate the percentage of their ‘love’ according to their names. The software requires the following things:
The length of the shortest string that contains the names as subsequence.
Total number of unique shortest strings which contain the names as subsequence.
Now your task is to find these parts.
Input
Input starts with an integer T (≤ 125), denoting the number of test cases.Each of the test cases consists of two lines each containing a name. The names will contain no more than 30 capital letters.
Output
For each of the test cases, you need to print one line of output. The output for each test case starts with the test case number, followed by the shortest length of the string and the number of unique strings that satisfies the given conditions.You can assume that the number of unique strings will always be less than 263. Look at the sample output for the exact format.
Sample Input
3USA
USSR
LAILI
MAJNU
SHAHJAHAN
MOMTAJ
Output for Sample Input
Case 1: 5 3Case 2: 9 40
Case 3: 13 15
题目大意
给你两个串s1,s2,要求找到一个串,并且这个串的字串包含s1,s2同时要尽量使这个串的长度小,输出这个串的长度并输出方案个数(因为串不唯一)。思路
对于所求串的长度很好理解,就是两个串的长度之和减去他们的公共字串的长度。但是对于方案个数的求法就比较复杂,可以用一个三维数组cnt[i][j][url=0相关文章推荐
- HDU 3368--搜索
- 用PHP的GD库把图片的背景替换成透明背景
- HDU 3366
- Silex:基于Symfony组件的微型框架简介
- 【NBUTOJ】-1651-Red packet(二分)
- 在windows7中安装xgboost
- Codeforces 439C Devu and Partitioning of the Array
- paper 88:人脸检测和识别的Web服务API
- CMake编译opencv和argc、argv含义
- C#中List与IList的区别
- 培训期间小作业~切换图片
- 基本控件使用(三)(触摸,CallFunc,Schedule)
- Google Chrome 中安装 PostMan 扩展
- Codeforces 439B Devu, the Dumb Guy
- poj 3020(二分图最小路径覆盖,拆点)
- HDOJ 1969 Pie
- vs2012加载EntityFrameWork框架,连接Oracel
- uWSGI 服务器的 uwsgi 协议究竟用在何处?
- 使用帮助 history 用法 echo输出闪烁作业
- newlisp转换10进制正整数到二进制串