2016 Multi-University Training Contest 5 1011 Two DP
http://acm.hdu.edu.cn/showproblem.php?pid=5791
HDU5791 Two
题意 :两个数组,多少个不连续子串相等
思路:
dp[i][j] :a串i结尾,b串j结尾的不连续子串数目个数
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=1e3+;
const int mod=1e9+;
const int inf=0x3f3f3f3f;
ll dp[maxn][maxn],a[maxn],b[maxn];
int n,m;
int main(){
while(~scanf("%d%d",&n,&m)){
for(int i=;i<=n;i++)scanf("%lld",&a[i]);
for(int i=;i<=m;i++)scanf("%lld",&b[i]);
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
dp[i][j]=(dp[i-][j]+dp[i][j-]-dp[i-][j-]+(a[i]==b[j]?dp[i-][j-]+:)+mod)%mod;
}
}
printf("%lld\n",dp[n][m]);
}
return ;
}
2016 Multi-University Training Contest 5 1011 Two DP的更多相关文章
- 2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...
- 2016 Multi-University Training Contest 3 1011【鸽巢原理】
题解: 坐标(0,m)的话,闭区间,可能一共有多少曼哈顿距离? 2m 但是给一个n,可能存在n(n+1)/2个曼哈顿距离 所以可以用抽屉原理了 当n比抽屉的数量大,直接输出yes 不用计算 那...N ...
- 2016 Al-Baath University Training Camp Contest-1 E
Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...
- 2016 Al-Baath University Training Camp Contest-1 C
Description Rami went back from school and he had an easy homework about bitwise operations (and,or, ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- 2016 Al-Baath University Training Camp Contest-1 J
Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...
- 2016 Al-Baath University Training Camp Contest-1 I
Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...
- 2016 Al-Baath University Training Camp Contest-1 H
Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...
- 2016 Al-Baath University Training Camp Contest-1 G
Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...
随机推荐
- HttpServletRequestWrapper的使用
老大给了一个很实际的需求:有段程序,使用Http的方式与合作商交互,而且是明文传输数据.我方的代码已经打包放在服务器上运行了很长时间,这时合作商突然要求修改数据传输的方式,要求加密后再传输,而我方的原 ...
- Java学习笔记之:Java的数据类型
一.介绍 变量就是申请内存来存储值.也就是说,当创建变量的时候,需要在内存中申请空间. 内存管理系统根据变量的类型为变量分配存储空间,分配的空间只能用来储存该类型数据. Java语言提供了八种基本类型 ...
- JavaScript基础精华03(String对象,Array对象,循环遍历数组,JS中的Dictionary,Array的简化声明)
String对象(*) length属性:获取字符串的字符个数.(无论中文字符还是英文字符都算1个字符.) charAt(index)方法:获取指定索引位置的字符.(索引从0开始) indexOf(‘ ...
- Shell 是个什么玩意
Shell的定义: 计算机分为软件和硬件,管理计算机硬件的是操作系统,也就是我们说的kernel,而这个核心是需要被保护起来的. 那我们如何通过软件与硬件进行沟通,让硬件执行我们要完成的指令呢? 这个 ...
- js问题总结
.removeClass(" ") 移除一个css样式 $("#popUpBox i").removeClass("channel_icon" ...
- [POJ1330]Nearest Common Ancestors(LCA, 离线tarjan)
题目链接:http://poj.org/problem?id=1330 题意就是求一组最近公共祖先,昨晚学了离线tarjan,今天来实现一下. 个人感觉tarjan算法是利用了dfs序和节点深度的关系 ...
- git跨平台换行符不兼容
https://help.github.com/articles/dealing-with-line-endings/#platform-all
- java.lang.NoClassDefFoundError: javax/wsdl/OperationType
You should find the javax.wsdl package inside wsdl4j.jar Check for the line starting with 'Found IBM ...
- 在ASP.NET中如何判断用户IE浏览器的版本
f ( Request.Browser.MajorVersion == ) { // to do } ................................................. ...
- LA 2218 (半平面交) Triathlon
题意: 有n个选手,铁人三项有连续的三段,对于每段场地选手i分别以vi, ui 和 wi匀速通过. 对于每个选手,问能否通过调整每种赛道的长度使得他成为冠军(不能并列). 分析: 粗一看,这不像一道计 ...