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 ...
随机推荐
- C#中SaveFileDialog 和OpenFileDialog 的用法
1.OpenFileDialog private void btnOpen_Click(object sender, EventArgs e) { OpenFileDialog ofd = new O ...
- 77. Combinations
题目: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For ex ...
- servlet request.getParamter 有时获取参数为null
他妈的,参数有时可以获取,有时又不行,折腾了好久,把tomcat换成8.0的,之前用apache-tomcat-7.0.67
- hdu 4825 Xor Sum (建树) 2014年百度之星程序设计大赛 - 资格赛 1003
题目 题意:给n个数,m次询问,每次给一个数,求这n个数里与这个数 异或 最大的数. 思路:建一个类似字典数的数,把每一个数用 32位的0或者1 表示,查找从高位向底位找,优先找不同的,如果没有不同的 ...
- Oracle存储过程格式
create or replace procedure sp_test ( -- 此地写传入的值 v_tjfs varchar2, --不用申明长度 v_kssj varchar2, v_ret ou ...
- Jqgrid入门-Jqgrid列数据拖动(七)
上一章提到在Jqgrid中如何设置二级表头,这一章节主要探讨Jqgrid表格里面的数据如果实现拖动功能,比如你想把第一行的数据拖到当前页的最后一行,或者其他位置. Jqgrid表格插件自己没有 ...
- BZOJ3218: a + b Problem
题解: 先做60分... 考虑最小割,连边容量为需要付出的代价.不妨设在s割为黑色,t割为白色. (s,i,b[i])(i,t,w[i]) 关于奇怪,因为不是按份数来的.所以我们这样建图: (i,i+ ...
- hdu 4690 EBCDIC
还有什么好说的呢?打表题= = #include<cstdio> #include<cstring> #include<algorithm> #include< ...
- JetBrains优秀工具推荐
1.JAVA开发工具 IDEA IDEA 全称 IntelliJ IDEA,是Java语言开发的集成环境,IntelliJ在业界被公认为最好的Java开发工具之一,尤其在智能代码助手.代码自动提示.重 ...
- 使用源代码安装lnmp
一.安装nginx前,安装pcre. # tar zxvf pcre-8.12.tar.gz# ./configure# make# make install 二.安装nginx # tar zxvf ...