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. Word、Excel、PPT 2016、2013、2010、2007 没有保存或断电导致文件丢失怎么恢复?

    1. 前言 没有保存文档还能恢复吗?死机.断电.蓝屏导致来不及保存文档,还能恢复吗?答案当然是可以的!Office中本身就有恢复文档的功能,可以帮助我们最大化的挽回损失. Office2013与Off ...

  2. SSH框架结合案例构建配置

    ssh框架概述 SSH是 struts+spring+hibernate的一个集成框架,是目前比较流行的一种Web应用程序开源框架.区别于 Secure Shell . 集成SSH框架的系统从职责上分 ...

  3. oracle 、mysql 取昨天 前天 本周 数据

    查询今天数据: SELECT COUNT(1) FROM T_CALL_RECORDS WHERE TO_CHAR(T_RKSJ,'YYYY-MM-DD')=TO_CHAR(SYSDATE,'YYYY ...

  4. Comet OJ Contest #3

    A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 ...

  5. PHP传引用赋值底层的变化

    $a = 3;$b = &$a;//传引用,即地址赋值 使用xdebug_debug_zval('a');使用xdebug_debug_zval('b');运行结果为:a:(refcount= ...

  6. (九)Struts标签基础(二)

    2.3 非表单标签 2.3.1 <s:actionerror>标签, this.addActionError("错误信息1");   //使用addActionErro ...

  7. MySQL高版本默认密码查找

    解决方式如下: 1:找到mysql的安装目录到跟目录下找到Data文件夹 2:打开Data/文件夹找到一个以.err结尾的文件用记事本打开,里面记录了你安装Mysql的一些日志,其中就记录了你的初始密 ...

  8. ES 6 日期util.js =>

    微信小程序demo const formatTime = date => { const year = date.getFullYear() const month = date.getMont ...

  9. java小工具:通过URL连接爬取资源(图片)

    java语言编写一个简单爬取网站图片工具,实现简单: 通过 java.net.HttpURLConnection 获取一个URL连接 HttpURLConnection 连接成功返回一个java.io ...

  10. luogu题解 P2886 【牛继电器Cow Relays】-经过K边最短路&矩阵

    题目链接: https://www.luogu.org/problemnew/show/P2886 Update 6.16 最近看了下<算法导论>,惊奇地发现在在介绍\(APSP\) \( ...