CodeForces - 1000D Yet Another Problem On a Subsequence
好智障的一个dp啊,一段开头的数字相当于下面要跟多少个数,直接滚动数组dp就行了。。。
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1005,ha=998244353; inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;} int f[N],n,a[N]; int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",a+i); f[0]=1; for(int i=1,now;i<=n;i++){
now=f[0];
for(int j=0;j<n;j++) ADD(f[j],f[j+1]);
if(a[i]>0&&a[i]+i<=n) ADD(f[a[i]],now);
} ADD(f[0],ha-1),printf("%d\n",f[0]); return 0;
}
CodeForces - 1000D Yet Another Problem On a Subsequence的更多相关文章
- D - Yet Another Problem On a Subsequence CodeForces - 1000D (DP,组合数学)
D - Yet Another Problem On a Subsequence CodeForces - 1000D The sequence of integers a1,a2,-,aka1,a2 ...
- 【codeforces 750E】New Year and Old Subsequence
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 766A】Mahmoud and Longest Uncommon Subsequence
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- [codeforces 528]B. Clique Problem
[codeforces 528]B. Clique Problem 试题描述 The clique problem is one of the most well-known NP-complete ...
- codeforces.com/contest/325/problem/B
http://codeforces.com/contest/325/problem/B B. Stadium and Games time limit per test 1 second memory ...
- Codeforces 442B Andrey and Problem(贪婪)
题目链接:Codeforces 442B Andrey and Problem 题目大意:Andrey有一个问题,想要朋友们为自己出一道题,如今他有n个朋友.每一个朋友想出题目的概率为pi,可是他能够 ...
- CodeForces 867B Save the problem
B. Save the problem! http://codeforces.com/contest/867/problem/B time limit per test 2 seconds memor ...
- Codeforces 776D The Door Problem
题目链接:http://codeforces.com/contest/776/problem/D 把每一个钥匙拆成两个点${x,x+m}$,分别表示选不选这把钥匙. 我们知道一扇门一定对应了两把钥匙. ...
- codeforces 803G Periodic RMQ Problem
codeforces 803G Periodic RMQ Problem 题意 长度为\(1e5\)的数组复制\(1e4\)次,对新的数组进行区间覆盖和区间最小值查询两种操作,操作次数\(1e5\). ...
随机推荐
- 20155335俞昆《java程序设计》第三周总结
20155335 2006-2007-2 <Java程序设计>第三周学习总结 ## 教材学习内容总结 首先,关键是区基本类型和类类型,,产生对象必须定义类,类是一个概念,并不存在,对 ...
- 发福利喽稀疏FFT
附介绍: 四位来自麻省理工学院的研究人员蒂娜·卡塔比(Dina Katabi).海塞姆·哈桑(Haitham Hassanieh).比欧特·因迪克(Piotr Indyk)和埃里克·普里斯(Eric ...
- base--AuditObject
//参考base-4.0.2.jarpublic class AuditObject extends HashMap<String, Object> implements TimeRefe ...
- Android控件——监听按钮的点击事件
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAroAAAFTCAIAAABZPDiZAAAgAElEQVR4nOy9918UWfb///1jdu2uBs
- mysql之数据库操作进阶(三)
环境信息 数据库:mysql-5.7.20 操作系统:Ubuntu-16.04.3 查询 条件查询 # 使用where关键字 select * from 表名 where 条件 # 比较运算符 > ...
- 【EverydaySport】健身笔记——背部训练
背部训练大致可以分为两种. 1 下拉式动作 躯干纵向上下位移的动作 典型代表 这样的下拉类动作 针对的是背阔肌 也就是两边像翅膀一样的部分 2 垂直于躯干的方向作用 向内拉 主要针对的是,背部的中部 ...
- python基础===discover函数介绍
discover(start_dir,pattern='test*.py',top_level_dir=None) 找到指定目录下所有测试模块,并可递归查到子目录下的测试木块,只有匹配到的文件名才会被 ...
- C# 使用HttpWebRequest Post提交数据,携带Cookie和相关参数示例
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- linux和ubuntu防火墙相关命令
1.永久有效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2.即刻生效 开启: service iptables start 关闭: se ...
- 【bzoj1024】生日蛋糕
一开始想dp 后来发现既然要均等,又看了下数据条件 暴力就能做. #include<bits/stdc++.h> using namespace std; ; int x,y,n; dou ...