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 ...
随机推荐
- Go语言的优点(oschina讨论)
Go语言的优点:并发/网络/性能/工具(fmt/pprof/test)/标准库(http/json/log/flags/atomic)/GoogleGo语言垃圾回收器真正致命的缺陷是,会导致整个进程不 ...
- C++:类的组合
在类中定义的数据成员一般都是基本数据类型或服复合数据类型.但是还可以根据需要使用 其他类的对象作为正在声明的数据成员.复杂的对象还可以有比较简单的对象一某种方式组合 而成,复杂对象和组成它的简单对象之 ...
- HDU 4358 Boring counting 树状数组+思路
研究了整整一天orz……直接上官方题解神思路 #include <cstdio> #include <cstring> #include <cstdlib> #in ...
- ios中addtarget的用法
1.addtarget 的.部分使用事件没有直接的操作方式,需要进行调用.就要用addTarget. - (void)setupCustomView { self.customView = [[CHV ...
- HDU 4717 The Moving Points(三分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...
- 面试题_1_to_16_多线程、并发及线程的基础问题
多线程.并发及线程的基础问题 1)Java 中能创建 volatile 数组吗?能,Java 中可以创建 volatile 类型数组,不过只是一个指向数组的引用,而不是整个数组.我的意思是,如果改变引 ...
- UITableViewCell上的按钮点击事件处理
转自: http://www.aichengxu.com/view/42871 UITableViewCell上的按钮点击事件处理,有需要的朋友可以参考下. 今天突然做项目的时候,又遇到处理自定义的 ...
- UVa 10285 Longest Run on a Snowboard【记忆化搜索】
题意:和最长滑雪路径一样, #include<iostream> #include<cstdio> #include<cstring> #include <c ...
- BZOJ2229: [Zjoi2011]最小割
题解: 真是一道神题!!! 大家还是围观JZP的题解吧(网址找不到了...) 代码: #include<cstdio> #include<cstdlib> #include&l ...
- Java [Leetcode 260]Single Number III
题目描述: Given an array of numbers nums, in which exactly two elements appear only once and all the oth ...