Educational Codeforces Round 46 (Rated for Div. 2) D

dp[i]表示一定包含第I个点的好的子序列个数,那么最终答案就是求dp[0] + dp[1] + .... + dp[n-1]
最终的子序列被分成了很多块,因此很明显我们枚举第一块,第一块和剩下的再去组合,然后我们为了保证没有重复,我们需要保证第一块不同,然而第一块的大小是固定的,因此我们可以选择枚举第一块最后一个数,这样第一块就肯定不会相同了,也可以计算
const ll P = 998244353;
ll dp[maxn];
int N = 1000;
ll comb[maxn][maxn];
int main(){
for(int i=0;i<=N;i++)
comb[i][0]=comb[i][i]=1;
for(int i=2;i<=N;i++)
for(int j=1;j<N;j++)
comb[i][j]=(comb[i-1][j]+comb[i-1][j-1])%P;
int n;
cin >> n;
vector<int> a(n);
for(int i = 0 ; i < n ; i++) {
cin >> a[i];
}
dp[n]=1;
ll ans=0;
for(int i = n - 1 ; i >= 0 ; i--){
if(a[i] <= 0 ) continue;
ll sum = 0;
for(int j = n ; j >= i + a[i] + 1 ; j--){
sum = (sum + dp[j]) % P;
dp[i] = (dp[i] + comb[j - i - 2][a[i] -1] % P * sum % P) % P;
}
//cout<<dp[i]<<endl;
//cout<<ans<<endl;
ans= (ans+dp[i]) %P;
}
cout<<ans<<endl;
return 0;
}
Educational Codeforces Round 46 (Rated for Div. 2) D的更多相关文章
- Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses
Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #in ...
- Educational Codeforces Round 46 (Rated for Div. 2) C. Covered Points Count
Bryce1010模板 http://codeforces.com/problemset/problem/1000/C 题意:问你从[l,r]区间的被多少条线覆盖,列出所有答案. 思路:类似括号匹配的 ...
- Educational Codeforces Round 46 (Rated for Div. 2) B. Light It Up
Bryce1010模板 http://codeforces.com/problemset/problem/1000/B 思路:先用两个数组sumon[]和sumoff[]将亮着的灯和灭的灯累计一下. ...
- Educational Codeforces Round 46 (Rated for Div. 2) A. Codehorses T-shirts
Bryce1010模板 http://codeforces.com/problemset/problem/1000/A 题意: 问你将一种类型的衣服转换成另一种的最小次数. #include<b ...
- Educational Codeforces Round 46 (Rated for Div. 2)
A - Codehorses T-shirts 思路:有相同抵消,没有相同的对答案+1 #include<bits/stdc++.h> #define LL long long #defi ...
- Educational Codeforces Round 46 (Rated for Div. 2) D. Yet Another Problem On a Subsequence
这个题是dp, dp[i]代表以i开始的符合要求的字符串数 j是我们列举出的i之后一个字符串的开始地址,这里的C是组合数 dp[i] += C(j - i - 1, A[i]] )* dp[j]; # ...
- Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序
Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] 给你 ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
随机推荐
- error C2338: No Q_OBJECT in the class with the signal (NodeCreator.cpp)
在Qt中,当派生类需要用到信号与槽机制时,有两个要求. 1.该类派生自QObject类. 2.类中有Q_OBJECT宏. 本次报错的原因就是因为没有在类中添加Q_OBJECT宏. 而我的出错原因更傻逼 ...
- C标准库与嵌入式
stddef.h,其中包括size_t,sizeof函数返回值,不同平台的大小不一致 Size and pointer difference types[edit] The C language sp ...
- Linux中awk抽取包含某字段的整行日志
命令示例:awk '{if($0~"listAuths") print}' xxx.log 解释说明:抽取xxx.log整个日志文件中,包含“listAuths”的行,打印输出
- light oj 1095 - Arrange the Numbers排列组合(错排列)
1095 - Arrange the Numbers Consider this sequence {1, 2, 3 ... N}, as an initial sequence of first N ...
- 论文翻译:Speech Enhancement Based on the General Transfer Function GSC and Postfiltering
论文地址:基于通用传递函数GSC和后置滤波的语音增强 博客作者:凌逆战 博客地址:https://www.cnblogs.com/LXP-Never/p/12232341.html 摘要 在语音增强应 ...
- 关于宏MACRO,我们需要知道的事
一.先从最宏观的角度来了解宏,这里的宏观角度是指程序的运行流程: 1,提交代码后,SAS先把代码读取储存到堆栈中: 2,用文本扫描插件来扫描堆栈中的代码,从上到下,从左到右: 3,扫描到一个分号,则编 ...
- 前端项目引入Echarts中的dataTool的正确方式
使用echarts画箱线图时调用echarts.dataTool.prepareBoxplotData() 报错:"echarts.dataTool.prepareBoxplotData i ...
- 【GET TIPS】Chrome所见即所得的截图技巧
精简的前言: 对,我就是想说下事情的来龙去脉.您要不想听,就把耳朵捂起来23333. 想截个新冠肺炎病毒,全国确诊人数今日增长的图,以确定非湖北地区不再明显增长. 但由于网页需要的内容分布在两页,需要 ...
- 前端之gojs插件的基本使用
gojs是一个前端插件,可以通过代码动态的生成流程图,各自展示图 参考网址:https://gojs.net/latest/index.html 如果你想使用,需要先下载对应的文件 我们能用的到的其实 ...
- StarUML之九、starUML的一些特殊属性的说明
UML的扩充性机制允许你在控制的方式下扩充UML语言. 这一类的机制包括:stereotype,标记值.约束. Stereotype扩充了UML的词汇表,允许你创建新的建筑块,这些建筑块从已有的继承而 ...