题意:给定一个非降序a与非升序b数组,要求从n个数,每个数无限个构建相同m长度成对不同的a,b数组并满足bi>=ai,求出不同组数的数量
思路:还以为是组合数学,没看到a,b数组的特性,其实是道思维题。
b1>=b2>=...bm>=a1>=a2>=..>=am,构建一个非递减数组就行了。求出构建不同非递减数组的数量。简单的递推一下,每一个m长度的数组都是由长度m-1,不同n的数组末尾加n构建而来的。
dp[i][j]=(wdp[i][j]+dp[k][j-1])%MOD;
O(n^2*m)的时间复杂度跑一遍枚举递推就行了
多了一些组合数学的代码,忽略就行
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<bitset>
#include<cmath>
#include<array>
#include<atomic>
#include<sstream>
#include<stack>
#include<iomanip>
//#include<bits/stdc++.h>
//#define int ll
#define IOS std::ios::sync_with_stdio(false);std::cin.tie(0);
#define pb push_back
#define endl '\n'
#define x first
#define y second
#define Endl endl
#define pre(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,b,a) for(int i=b;i>=a;i--)
#define si(x) scanf("%d", &x);
#define sl(x) scanf("%lld", &x);
#define ss(x) scanf("%s", x);
#define YES {puts("YES");return;}
#define NO {puts("NO"); return;}
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<double, double> PDD;
typedef pair<ll, ll> PLL;
const int N = 1010, M = 2 * N, B = N, MOD = int(1e9+7);
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
//int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
int dx[8] = { 1,2,2,1,-1,-2,-2,-1 }, dy[8] = { 2,1,-1,-2,-2,-1,1,2 };
int n, m, k;
ll fact[N], infact[N];
ll dp[N][40];
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lowbit(ll x) { return x & -x; }
ll qmi(ll a, ll b, ll MOD) {
ll res = 1;
while (b) {
if (b & 1) res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
inline void init()
{
fact[0] = infact[0] = 1;
pre(i, 1, n)
{
fact[i] = fact[i - 1] * i % MOD;
infact[i] = infact[i - 1] * qmi(i, MOD - 2, MOD) % MOD;
}
auto C = [&](int b, int a) {
return fact[a] * infact[a - b] % MOD * infact[b] % MOD;
};
for (int i = 1; i <= 1000; i++)
{
dp[i][1] = 1;
}
for (int m = 2; m <= 20; m++)
{
for (int n = 1; n <= 1000; n++)
{
for (int k = 1; k <= n; k++)
dp[n][m] = (dp[n][m] + dp[k][m - 1]) % MOD;
}
}
}
void slove()
{
cin >> n >> m;
m = m << 1;
ll sum = 0;
pre(i, 1, n)
sum = (sum + dp[i][m]) % MOD;
cout << sum << endl;
return;
}
signed main()
{
//IOS;
int _ = 1;
//si(_);
init();
while (_--)
{
slove();
}
return 0;
}
/*
*/