yyb大佬的博客

这线段期望好神啊。。。

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

  1. Codeforces Round #551 (Div. 2) D. Serval and Rooted Tree (树形dp)

    题目链接 题意:给你一个有根树,假设有k个叶子节点,你可以给每个叶子节点编个号,要求编号不重复且在1-k以内.然后根据节点的max,minmax,minmax,min信息更新节点的值,要求根节点的值最 ...

  2. Codeforces Round #551 (Div. 2) D. Serval and Rooted Tree (树形dp)

    题目:http://codeforces.com/contest/1153/problem/D 题意:给你一棵树,每个节点有一个操作,0代表取子节点中最小的那个值,1代表取子节点中最大的值,叶子节点的 ...

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

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

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

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

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

  8. Codeforces Round #551 (Div. 2) E. Serval and Snake (交互题)

    人生第一次交互题ac! 其实比较水 容易发现如果查询的矩阵里面包含一个端点,得到的值是奇数:否则是偶数. 所以只要花2*n次查询每一行和每一列,找出其中查询答案为奇数的行和列,就表示这一行有一个端点. ...

  9. Codeforces Round #509 (Div. 2) F. Ray in the tube(思维)

    题目链接:http://codeforces.com/contest/1041/problem/F 题意:给出一根无限长的管子,在二维坐标上表示为y1 <= y <= y2,其中 y1 上 ...

随机推荐

  1. 暴力解决HTMLTestRunner出现dict() ->new empty dictionary的问题

    在使用ddt数据驱动之后,HTMLTestRunner报告的用例名称之后出现dict() ->new empty dictionary,如下图所示: 经排查,发现是因为ddt源码中test_do ...

  2. JAVA_split 字符串按照 . 分割

    split 按照 . 分割字符串时 需要进行转义 代码: String[] str = obj_str.split("\\.") split 按照 \ 分割字符串时 需要多次转义 ...

  3. Ubuntu将自带的python3升级

    一.这里演示的是将python3.5升级到python3.6 1.添加安装源,在命令行输入如下命令: sudo add-apt-repository ppa:jonathonf/python-3.6 ...

  4. linux下添加用户并将文件夹授权给某一个用户

    ### linux下添加用户并将文件夹授权给某一个用户 背景:在做一个项目时,需要外包的前端人员调试测试环境的页面,但是又不能给他服务器的账号信息,就在服务器上新添加一个子账户,再给这个账户项目文件的 ...

  5. ggplot2|详解八大基本绘图要素

    本文首发于微信公众号 *“ 生信补给站 ” ,期待您的关注!!!* 原文链接:https://mp.weixin.qq.com/s?__biz=MzIyNDI1MzgzOQ==&mid=265 ...

  6. hdu 4324

    思路待整理 #include<cstdio> #include<iostream> #include<vector> #include<queue> # ...

  7. 联想U310 安装系统后无法识别机械硬盘处理

    过程: 原30G的固态更换成250G的 mSATA固态,去掉机械硬盘,开始在固态里安装系统, 系统用PE登录,安装正版Win7 64B 专业版, 安装结束,接上机械硬盘, *PE下,可以正常识别2块硬 ...

  8. R语言做逻辑回归

    前面写过一个多分类的逻辑回归,现在要做一个简单的二分类,用glm函数 导入csv格式如下: mydata<-read.csv("D://li.csv",header=T) c ...

  9. 前端关于 superSlide.js 使用,一款基于jquery的前端控件

    1引用jQuery.js 和 jquery.SuperSlide.js 2 编写HTML ** 以下是默认的HTMl结构,分别是 ".hd" 里面包含ul, ".bd&q ...

  10. Python练习_高阶函数_day11

    1,写函数,传入n个数,返回字典{‘max’:最大值,’min’:最小值} 例如:min_max(2,5,7,8,4) 返回:{‘max’:8,’min’:2}(此题用到max(),min()内置函数 ...