题库练习 Short Permutation Problem
← 上一题 下一题 →

A16439 | Short Permutation Problem

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

[Xomu - Last Dance](https://soundcloud.com/xomuu/xomu-last-dance)

⠀



You are given an integer $n$ .

For each $(m, k)$ such that $3 \leq m \leq n+1$ and $0 \leq k \leq n-1$ , count the permutations of $[1, 2, ..., n]$ such that $p_i + p_{i+1} \geq m$ for exactly $k$ indices $i$ , modulo $998\,244\,353$ .

输入格式

The input consists of a single line, which contains two integers $n$ , $x$ ( $2 \leq n \leq 4000$ , $1 \leq x < 1\,000\,000\,007$ ).

输出格式

Let $a_{m,k}$ be the answer for the pair $(m, k)$ , modulo $998\,244\,353$ .

Let $$$$\large S = \sum_{m=3}^{n+1} \sum_{k=0}^{n-1} a_{m,k}x^{mn+k}\phantom{0}. $$ </p><p>Output a single line with an integer: $S$ modulo $1\\,000\\,000\\,007$ .</p><p>Note that using two different modulos is intentional. We want you to calculate all the $a\_{m,k}$ modulo $998\\,244\\,353$ , then treat them like integers in the range $\[0, 998\\,244\\,352\]$ , and hash them modulo $1\\,000\\,000\\,007$$$.

输入输出样例

输入 #1
3 2
输出 #1
77824
输入 #2
4 1000000000
输出 #2
30984329
输入 #3
8 327869541
输出 #3
85039220
输入 #4
4000 1149333
输出 #4
584870166
C++ 编辑器
输入
输出