codeforces Educational Codeforces Round 80 (Rated for Div. 2) C - Two Arrays(简单dp)
程序员文章站
2022-03-12 16:57:32
...
题意:构造出两个数组a和b,a和b数组的每一个数范围是1到n,长度都位m,且ai严格小于等于bi,a数组升序,b数组降序问有多少种构造方案。
思路:因为ai严格小于bi,所以会发现将a数组顺序,b数组逆序所组成的新数组是严格递增的,这样的话数组就很好构造了,设dp[i[[j[为数组长度为i,最后一位为j的方案数。假设第j位是5,那么前面是不是只能从1,2,3,4,5里选?把他们的方案加起来就行,转移方程位dp[i[[j]=(dp[i][j]+dp[i-1][k])(k小于等于j)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+1;
const int mod=1e9+7;
int n,m;
ll dp[maxn][maxn];
int main()
{
scanf("%d %d",&n,&m);
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;++i) dp[1][i]=i;
for(int i=2;i<=2*m;++i)
for(int j=1;j<=n;++j)
{
for(int k=1;k<=j;++k)
dp[i][j]=(dp[i][j]+dp[i-1][k])%mod;
}
cout<<dp[2*m][n]<<endl;
}
推荐阅读
-
Educational Codeforces Round 85 (Rated for Div. 2) C. Circle of Monsters(前缀和 预处理 贪心)
-
Educational Codeforces Round 99 (Rated for Div. 2) C. Ping-pong
-
C. Mortal Kombat Tower(动态规划)Educational Codeforces Round 95 (Rated for Div. 2)
-
Educational Codeforces Round 88 (Rated for Div. 2)C. Mixing Water[题解](数学)
-
Educational Codeforces Round 95 (Rated for Div. 2)C. Mortal Kombat Tower【dp】
-
Educational Codeforces Round 86 (Rated for Div. 2)---C
-
Educational Codeforces Round 83 (Rated for Div. 2) D. Count the Arrays
-
codeforces Educational Codeforces Round 80 (Rated for Div. 2) D - Minimax Problem(状压)
-
Educational Codeforces Round 80 (Rated for Div. 2)
-
Educational Codeforces Round 62 (Rated for Div. 2) C