Educational Codeforces Round 80 (Rated for Div. 2)C(DP)
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9+;
long long pre[][],temp[][];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m;
cin>>n>>m;
for(int i=;i<=n;++i){
pre[][i]=;
temp[][i]=;
}
for(int i=;i<=m;++i)//当前位
for(int j=;j<=n;++j)//第i位以数字j结尾
for(int k=;k<=j;++k)//保证非降序
pre[i][j]=(pre[i][j]+pre[i-][k])%mod;//状态转移
for(int i=;i<=m;++i)//当前位
for(int j=;j<=n;++j)//第i位以数字j结尾
for(int k=j;k<=n;++k)//保证非升序
temp[i][j]=(temp[i][j]+temp[i-][k])%mod;//状态转移
long long ans=;
for(int i=;i<=n;++i)//枚举第二个数组以数字i作为结尾
for(int j=;j<=i;++j)//枚举第一个数组以数字j作为结尾,j<=i保证了第一个数组最大的都小于等于第二个数组最小的,所以整个数组全部满足小于等于关系
ans=(ans+(temp[m][i]*pre[m][j])%mod)%mod;//相乘得到答案
cout<<ans;
return ;
}
Educational Codeforces Round 80 (Rated for Div. 2)C(DP)的更多相关文章
- Educational Codeforces Round 80 (Rated for Div. 2)E(树状数组,模拟,思维)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],mx[],a[],pos[],sum ...
- Educational Codeforces Round 80 (Rated for Div. 2)D(二分答案,状压检验)
这题1<<M为255,可以logN二分答案后,N*M扫一遍表把N行数据转化为一个小于等于255的数字,再255^2检验答案(比扫一遍表复杂度低),复杂度约为N*M*logN #define ...
- Educational Codeforces Round 57 (Rated for Div. 2)D(动态规划)
#include<bits/stdc++.h>using namespace std;char s[100007];long long a[100007];long long dp[100 ...
- Educational Codeforces Round 79 (Rated for Div. 2) Finished (A-D)
如果最大值比剩余两个加起来的总和+1还大,就是NO,否则是YES #include<bits/stdc++.h> using namespace std; int main(){ int ...
- Educational Codeforces Round 82 (Rated for Div. 2)E(DP,序列自动机)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],t[]; int n,m; ][]; ...
- Educational Codeforces Round 82 (Rated for Div. 2)D(模拟)
从低位到高位枚举,当前位没有就去高位找到有的将其一步步拆分,当前位多余的合并到更高一位 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&g ...
- Educational Codeforces Round 75 (Rated for Div. 2)D(二分)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;pair<int,int>a[20 ...
- Educational Codeforces Round 73 (Rated for Div. 2)D(DP,思维)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;long long a[300007],b[3 ...
- Educational Codeforces Round 72 (Rated for Div. 2)C(暴力)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;char s[200007];int a[20 ...
随机推荐
- [国家集训队] 拉拉队排练 - Manacher
用 Manacher 跑出回文串长,注意这里不需要偶数长度所以不需要对串做一些奇怪的处理 然后用前缀和搞一下,计算答案时跑快速幂即可 #include <bits/stdc++.h> us ...
- [CF269B] Greenhouse Effect - dp
给出 N 个植物,每个植物都属于一个品种,共计 m 个品种,分落在不同的位置上(在一个数轴上,而且数轴是无限长度的),保证读入的位置是按照升序读入的. 现在我们可以进行一个操作:取任意一个位置上的植物 ...
- clone()与clone(true)的用法
clone() 方法生成被选元素的副本,包含子节点.文本和属性. 使用 clone(true) 方法在clone()的基础上还包括克隆元素的事件处理器.
- layui table 超出自动换行
个人博客 地址:http://www.wenhaofan.com/article/20181120180507 layui 的table的的cell默认是超出hidden的,如果希望超出长度自动换行便 ...
- vue报错 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c ...
- BindingException: Invalid bound statement (not found)问题
- Excel VBA 如何在工作表上使用Option Button按钮
应用场景 在Excel的页面上放一个“确认”按钮,再放几个Option Button按钮,编写代码,点击“确认”按钮,判断出选择了哪个Option按钮, 然后根据选择不同的Option Button去 ...
- flask操作
models.py class CompanyGoodsModel(Base): id=Column(Integer, primary_key=True) company_id = Column(In ...
- 【算法学习记录-排序题】【PAT A1025】PAT Ranking
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhe ...
- Hog实例
1.计算Hog的特征得维度: #include <iostream> #include <opencv2/core/core.hpp> #include <opencv2 ...