Codeforces Round #551 (Div. 2) F. Serval and Bonus Problem (DP/FFT)
这线段期望好神啊。。。
还有O(nlogn)FFTO(nlogn)FFTO(nlogn)FFT的做法 Freopen大佬的博客
本蒟蒻只会O(n2)O(n^2)O(n2)
CODE
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
typedef long long LL;
const int MAXN = 4005;
inline void add(int &x, int y) { x += y; if(x >= mod) x -= mod; }
inline int qpow(int a, int b) {
int res = 1;
while(b) {
if(b & 1) res = 1ll * res * a % mod;
a = 1ll * a * a % mod; b >>= 1;
}
return res;
}
int n, l, k, f[2][MAXN][2];
int main () {
scanf("%d%d%d", &n, &k, &l);
int now = 0, N = 2*n+1;
f[0][0][0] = 1;
for(int i = 1; i <= N; ++i) {
now ^= 1; memset(f[now], 0, sizeof f[now]);
for(int j = 0; j < i; ++j) {
add(f[now][j+1][0], f[now^1][j][0]),
add(f[now][j+1][1], f[now^1][j][1]);
if(j)
add(f[now][j-1][0], 1ll * f[now^1][j][0] * j % mod),
add(f[now][j-1][1], 1ll * f[now^1][j][1] * j % mod);
if(j >= k)
add(f[now][j][1], f[now^1][j][0]);
}
}
int ans = 1ll * f[now][0][1] * l % mod * qpow(2, n) % mod;
for(int i = n+1; i <= N; ++i) ans = 1ll * ans * qpow(i, mod-2) % mod;
printf("%d\n", (ans + mod) % mod);
}
Codeforces Round #551 (Div. 2) F. Serval and Bonus Problem (DP/FFT)的更多相关文章
- Codeforces Round #551 (Div. 2) D. Serval and Rooted Tree (树形dp)
题目链接 题意:给你一个有根树,假设有k个叶子节点,你可以给每个叶子节点编个号,要求编号不重复且在1-k以内.然后根据节点的max,minmax,minmax,min信息更新节点的值,要求根节点的值最 ...
- Codeforces Round #551 (Div. 2) D. Serval and Rooted Tree (树形dp)
题目:http://codeforces.com/contest/1153/problem/D 题意:给你一棵树,每个节点有一个操作,0代表取子节点中最小的那个值,1代表取子节点中最大的值,叶子节点的 ...
- Codeforces Round #524 (Div. 2) F. Katya and Segments Sets(主席树)
https://codeforces.com/contest/1080/problem/F 题意 有k个区间,区间的种类有n种,有m个询问(n,m<=1e5,k<=3e5),每次询问a,b ...
- Codeforces Round #346 (Div. 2)---E. New Reform--- 并查集(或连通图)
Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory lim ...
- Codeforces Round #524 (Div. 2) C. Masha and two friends(矩形相交)
C. Masha and two friends time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces Round #551 (Div. 2)A. Serval and Bus
A. Serval and Bus time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #551 (Div. 2)B. Serval and Toy Bricks
B. Serval and Toy Bricks time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces Round #551 (Div. 2) E. Serval and Snake (交互题)
人生第一次交互题ac! 其实比较水 容易发现如果查询的矩阵里面包含一个端点,得到的值是奇数:否则是偶数. 所以只要花2*n次查询每一行和每一列,找出其中查询答案为奇数的行和列,就表示这一行有一个端点. ...
- Codeforces Round #509 (Div. 2) F. Ray in the tube(思维)
题目链接:http://codeforces.com/contest/1041/problem/F 题意:给出一根无限长的管子,在二维坐标上表示为y1 <= y <= y2,其中 y1 上 ...
随机推荐
- docker容器端口号、时区修改
一.修改端口号 在docker run创建并运行容器的时候,可以通过-p指定端口映射规则.但是,我们经常会遇到刚开始忘记设置端口映射或者设置错了需要修改.当docker start运行容器后并没有提 ...
- kubernetes ingress 在物理机上的nodePort和hostNetwork两种部署方式解析及比较
ingress controller在物理机上的两种部署方式 ingress controller(ingress-nginx)负责k8s中的7层负载均衡.其在物理机中有多种部署方式.本文中主要选择了 ...
- 【坑】springMvc 信息校验,读取不到错误配置信息的问题
文章目录 前言 ResourceBundleMessageSource 后记 前言 springMvc 的一大利器,validation 检验,通过注解,可以帮我们完成校验,很是顺手. 终极偷懒检验, ...
- wordpress5.0+中 Notice: Undefined index: HTTP_REFERER 问题解决
都说现在搭网站很简单了,但真遇到问题了还真不一定能解决. 这次搭建的网站是用的wordpress版本5.0.4,以为操作和以前的低版本一样,结果做出来还是遇到问题了. 网站搭好后,首页总在顶端出现一行 ...
- 病毒 | wordpress网站内容被篡改、自动跳转、变全英文的解决办法
去年10月开始,网站经常有文章被莫名其妙的篡改,而且后面还经常出现跳转到色情网站的问题,让人烦不胜烦,困扰了好几个月,最后终于解决了.这里特次记录和总结下此次恼人的事件. 时间:2018年10月 问题 ...
- 使用google的guova开发高并发下的接口限流
使用google的guova开发高并发下的接口限流 使用google的guova进行限流 1.guova的限流方式,在定时产生定量的令牌,令牌的数量限制了流量 2.增加一个订单接口限流类OrderRa ...
- Django中常用的那些模块路径
Django中常用的那些模块路径 from django.shortcuts import HttpResponse, render, redirect from django import temp ...
- AtCoder Grand Contest 040 A - ><
传送门 对于某个位置,只要知道这个位置往左最多的连续 $\text{<}$ 的数量 $x$ 和往右最多的连续 $\text{>}$ 的数量 $y$ 那么这个位置最小可能的数即为 $max( ...
- SpringCloud Hystrix 参数
hystrix.command.default和hystrix.threadpool.default中的default为默认CommandKey Command PropertiesExecution ...
- 怎样解决多层this指向全局对象window的问题
如下所示, 得到的结果里面, 第二个this指向的是window这个全局对象而非f2, 原因就是多层this造成的指向不明引起的. var a = { f1: function(){ console. ...