标签:source def size printf efi span mit 开始 子序列
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define DEP(i,a,b) for(int i=(a); i>=(b); i--)
#define N 1010
using namespace std;
typedef long long LL;
const LL mod = 998244353;
int n;
LL a[N], dp[N];
LL C[N][N];
int main()
{
scanf("%d", &n);
C[0][0] = 1;
REP(i, 1, n+1) {
C[i][0] = C[i][i] = 1;
REP(j, 1, i)
C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
}
REP(i, 1, n+1) scanf("%lld", &a[i]);
memset(dp, 0, sizeof(dp));
dp[n+1] = 1;
DEP(i, n, 1) {
if (a[i] <= 0) {dp[i] = 0; continue;}
REP(j, i+a[i]+1, n+2)
dp[i] = (dp[i] + (C[j-i-1][a[i]] * dp[j] % mod)) % mod;
}
LL res = 0;
REP(i, 1, n+1) res = (res + dp[i]) % mod;
printf("%lld\n", res);
return 0;
}
Educational Codeforces Round 46 D. Yet Another Problem On a Subsequence
标签:source def size printf efi span mit 开始 子序列
原文地址:https://www.cnblogs.com/RFisher/p/9248648.html