【动态规划】HDU 5791 Two】的更多相关文章

hdu 5791 Two Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1421    Accepted Submission(s): 630 Problem Description Alice gets two sequences A and B. A easy problem comes. How many pair of sequ…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5791 题目大意: A,B两个数列,问A的子集和B的子集相等的子集对数.子集内顺序按照数列顺序,相同的数字视为不同. 题目思路: [动态规划] f[i][j]表示A前i个数,B前j个数且第j个数必取的值.g[i][j]表示j不一定必取得值. ans=∑f[n][j]. // //by coolxxx //#include<bits/stdc++.h> #include<iostream>…
Two 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5791 Description Alice gets two sequences A and B. A easy problem comes. How many pair of sequence A' and sequence B' are same. For example, {1,2} and {1,2} are same. {1,2,4} and {1,4,2} are not sam…
动态规划就是寻找最优解的过程 最重要的是找到关系式 hdu 1003 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1003 题目大意:求最大字序列和,其实就是分成 以0结尾的序列 以1结尾的序列 以2结尾的序列 ... 以n结尾的序列 所以以n结尾的序列的最大值就是以n-1结尾的序列的最大值+n的值 或最大值是n的值 关系式: d[i]=max(d[i-1]+a[i],a[i]) d[i]为以i结尾的序列和的最大值,a[i]为第i个数的值 #in…
Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 41033    Accepted Submission(s): 14763 Problem Description Now I think you have got an AC in Ignatius.L's "Max Sum" problem…
http://acm.split.hdu.edu.cn/showproblem.php?pid=5791 题意: 给出两个序列,求这两个序列的公共子序列的总个数. 思路: 和LCS差不多,dp[i][j]表示第一个的前i个和第二个的前j个所包含的公共子序列的个数. 首先考虑a[i]≠b[j]的情况,此时应该容易推得dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]. 那么当a[i]=b[j]时,i和j这两个字符可以单独组成一个公共序列,然后前面dp[i-1][…
http://acm.hdu.edu.cn/showproblem.php?pid=5791 Two Problem Description   Alice gets two sequences A and B. A easy problem comes. How many pair of sequence A' and sequence B' are same. For example, {1,2} and {1,2} are same. {1,2,4} and {1,4,2} are not…
Two   Problem Description   Alice gets two sequences A and B. A easy problem comes. How many pair of sequence A' and sequence B' are same. For example, {1,2} and {1,2} are same. {1,2,4} and {1,4,2} are not same. A' is a subsequence of A. B' is a subs…
免费馅饼 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 36612    Accepted Submission(s): 12504 Problem Description 都 说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼.说来gameboy的人品实在是太好了,这馅饼别处都不掉, 就掉落在他身旁…
题意:给两个序列,求公共序列的个数 分析:很自然想到最长公共子序列的转移的转移形式,用dp[i][j]表示第一个串前i个 和第二个串前j个匹配的答案数量,a[i]==b[i],dp[i][j]=dp[i-1][j]+d[i][j-1]+1 a[i]!=b[i],dp[i][j]=dp[i-1][j]+dp[i][j]-1]-dp[i-1][j-1] 代码: #include<bits/stdc++.h> using namespace std; const int maxn=1e3+5; co…