LightOJ 1013 - Love Calculator LCS】的更多相关文章

题意:找一个串使给出的两个串都是它的子串,要求最短,求出最短长度,以及种类数. 思路:可以想到,当两个子串a,b拥有最长的公共子串为LCS时,那么可以求出的最短的串为lena+lenb-LCS. 那么接下来直接计算转移数就可以了,和平常求LCS的方法一样.DP[i][j][k]代表到选取了i个时已有j个a串的,k个b串的种类数. /** @Date : 2016-12-09-18.39 * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : ht…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1013 题意: 给你两个字符串,让你构造出一个长度最小的字符串,且它的子序列包含这两个字符串.问它的长度,和多少种情况. 思路: 长度的话就是lena + lenb - LCS,这个比较明显.情况数比较难算. dp[i][j][k]表示a字符串前i个字符 b字符串前j个字符构成长度为k的字符串有多少种情况. (1)a[i] == b[i] 就是dp[i][j][k] = dp[…
1013 - Love Calculator 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' ac…
http://www.lightoj.com/volume_showproblem.php?problem=1013   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 gene…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1013 #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #include <vector> using namespace std; ;…
思路:动态规划.设dp[i][j][k]表示用第一个串的前i隔字符和第二个串的前k隔字符组成长度为i的串的个数,那么:若s1[j+1] == s2[k+1] dp[i+1][j+1][k+1] += dp[i][j][k],否则:dp[i+1][j+1][k] += dp[i][j][k]; dp[i+1][j][k+1] += dp[i][j][k] #include<cstdio> #include<string> #include<cstring> #includ…
题目大意: 给你两个字符串A,B 要求一个最短的字符串C,使得A,B同时为C的子串. 问C最短长度是多少? C有多少种? 题目分析: 做这道题目的时候自己并没有推出来,看了网上的题解. 1.dp[C串的长度][包含A的字符个数][包含B的字符个数] = 种类数 状态转移:如果 A[i] == B[j] 那么 dp[k][i][j] = dp[k-1][i-1][j-1]. 就是说我最后一个字符是相同的那么我只要放一个就可以了. 如果 A[i] !=  B[j] 那么 dp[k][i][j] =…
免费做一样新 1004 - Monkey Banana Problem 号码塔 1005 - Rooks 排列 1013 - Love Calculator LCS变形 dp[i][j][k]对于第一个字符串i 到jLCS为k的方案数 1068 - Investigation 数位dp 能被K整数且各位数字之和也能被K整除的数 dp[i][j][k] 到第i位每位数字之和的余数为j 当前数字余数为k 1079 - Just another Robbery 01背包 全部钱之和为背包体积 不被抓的…
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单A+B] 1001 Opposite Task  [简单题] 1002 Country Roads[搜索题] 1003 Drunk[判环] 1004 Monkey Banana Problem [基础DP] 1006 Hex-a-bonacci[记忆化搜索] 1008 Fibsieve`s Fantabu…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=25839 思路:第一小问可以很快求出了,两个字符串的长度-LCS,然后第二问就要记忆化搜索了,dp[i][j][l]表示A串的前i个和B串的前j个组合,长度为l的组合数. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using…