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的更多相关文章

  1. Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses

    Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #in ...

  2. Educational Codeforces Round 46 (Rated for Div. 2) C. Covered Points Count

    Bryce1010模板 http://codeforces.com/problemset/problem/1000/C 题意:问你从[l,r]区间的被多少条线覆盖,列出所有答案. 思路:类似括号匹配的 ...

  3. Educational Codeforces Round 46 (Rated for Div. 2) B. Light It Up

    Bryce1010模板 http://codeforces.com/problemset/problem/1000/B 思路:先用两个数组sumon[]和sumoff[]将亮着的灯和灭的灯累计一下. ...

  4. Educational Codeforces Round 46 (Rated for Div. 2) A. Codehorses T-shirts

    Bryce1010模板 http://codeforces.com/problemset/problem/1000/A 题意: 问你将一种类型的衣服转换成另一种的最小次数. #include<b ...

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

    A - Codehorses T-shirts 思路:有相同抵消,没有相同的对答案+1 #include<bits/stdc++.h> #define LL long long #defi ...

  6. 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]; # ...

  7. Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序

    Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] ​ 给你 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 为了控制Bean的加载我使出了这些杀手锏

    故事一: 绝代有佳人,幽居在空谷 美女同学小张,在工作中遇到了烦心事.心情那是破凉破凉的,无法言喻. 故事背景是最近由于需求变动,小张在项目中加入了MQ的集成,刚开始还没什么问题,后面慢慢问题的显露出 ...

  2. python的Django构建web应用

    创建一个网上购物的网站 首先创建一个简单的python项目,然后在终端输入pip install django 安装Django框架 然后输入django-admin startproject pys ...

  3. DeBug Python神级工具PySnooper

    安装 pip3 install pysnooper import pysnooper @pysnooper.snoop() def number_to_bits(number): if number: ...

  4. filebeat+kafka

    kafka出现接收不到filebeat数据,最后发现版本兼容问题 filebeat换成  filebeat-7.4.2-linux-x86_64 kafka是docker-compose启动的,版本是 ...

  5. Oracle 重启监听

    对于DBA来说,启动和关闭oracle监听器是很基础的任务,但是Linux系统管理员或者程序员有时也需要在开发数据库中做一些基本的DBA操作,因此了解一些基本的管理操作对他们来说很重要. 本文将讨论用 ...

  6. [Linux]curl 获取本服务器公网IP

    curl ifconfig.me curl icanhazip.com curl curlmyip.com curl ip.appspot.com curl ipinfo.io/ip curl ipe ...

  7. Nginx-2.初学者使用

    原文 Nginx有一个master进程和几个worker进程.master进程用来读取和评估配置文件,以及维护worker进程.worker进程用来处理实际的请求.Nginx使用事件模型和基于操作系统 ...

  8. HDP之HBase性能调优

    (官方文档翻译及整理) 一.系统级调优 1.保证充足的RAM 2.64位的操作系统 3.Linux的swappiness设置为0 : sysctl vm.swappiness=10 vim /etc/ ...

  9. 2000_wideband extension of telephone speech using a hidden Markov model

    论文地址:基于隐马尔科夫模型的电话语音频带扩展 博客作者:凌逆战 博客地址:https://www.cnblogs.com/LXP-Never/p/12151866.html 摘要 本文提出了一种从l ...

  10. leetcode--js--Median of Two Sorted Arrays

     问题描述: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of ...