QOJ.ac

QOJ

Time Limit: 1.5 s Memory Limit: 512 MB Total points: 100

#7496. 嘘月

الإحصائيات

“我早已认不出你的眼睛,也没有在想念你的面容;

你还是没有说出再见,就化作黑夜离开了。”

赫尔德看着潮水,忽觉这不断上涨的潮水就像是持续上升的热情,它维持着热恋的时间,而激动的情绪又带给我们更多的热情。但是初识的热情终会逐渐平淡,又有多少人能在冷却的心跳中找到其中不变的节奏,走完这一生呢?

题目描述

赫尔德想对上面的问题进行探究,她想先做一些统计,于是她抽象了这个问题。

对于一个长为 $n$ 的排列,我们维护一个下标 $t$,初始 $t=m$。

重复以下过程:

  • 从下标在 $1\sim t$ 的元素中选一个没标记过的,并将其标记。若标记的数比上一次标记的数大且 $t< n$,则 $t$ 自增 $1$;否则结束此过程。在你进行第一次标记前,上一次标记的数视为 $0$。

我们称这样的排列是好的:

  • 存在某种方法,使得在经过若干次操作后,$t=n$。

现在,给定 $m$,求长为 $n$ 的好的排列在所有长为 $n$ 的排列中所占比例,对 $998244353$ 取模。换言之,若长为 $n$ 的好的排列一共有 $x$ 个,你需要输出 $\frac x{n!}$ 取模 $998244353$ 的结果。

有 $q$ 次询问,每次给出一个 $m$。

输入格式

第一行两个正整数 $n,q$。

第二行 $q$ 个正整数,表示每次询问的 $m_i$。保证询问升序且两两不同。

输出格式

对于每次询问一行一个整数表示答案对 $998244353$ 取模的值。

样例数据

input

5 3
1 2 3

output

291154603
249561089
1

explanation

可以使得 $t=n$ 的排列的数量分别为 $5,90,120$,排列总共有 $5!=120$ 种,所以分别需要输出 $\frac{5}{120},\frac{90}{120},\frac{120}{120}$。取模后即为样例输出中的答案。

$m=1$ 时,以下是所有可以使得 $t=n$ 的排列:

$$ \{1,2,3,4,5\},\{2,3,4,5,1\},\{1,3,4,5,2\},\{1,2,4,5,3\},\{1,2,3,5,4\} $$

$m=2$ 时,列出了一些可以使得 $t=n$ 的排列:

$$ \{1,4,2,3,5\},\{1,5,4,3,2\} $$

和一些不能使得 $t=n$ 的排列:

$$ \{5,4,3,2,1\},\{3,5,2,1,4\} $$

input

50 5
4 7 9 14 17

output

344293672
864377042
192544332
688054502
97923957

子任务

保证 $1\le q\le n\le 10^5$,$1\leq m_i \leq n$,询问的 $m_i$ 互不相同且升序排列。

子任务编号 $n \leq $ 特殊限制 分数
$1$ $5$ $ $ $7$
$2$ $200$ $23$
$3$ $2 \times 10^4$ $m = 1$ $9$
$4$ $2m_i \geq n$ $3$
$5$ $ $ $12$
$6$ $ $ $q = 1$ $36$
$7$ $ $ $10$

提示:$O(n^2)$ 能跑挺多点的。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.