Array Repairing

TimeLimit:5000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Given an integer $n$, a sequence $a[1..n]$ is randomly generated with equal probability, namely, $a_i \in [1,n]$, $\forall i \in [1,n]$. Note that it may be not a permutation of $1..n$.

To turn it into $a_i=i,\forall i \in [1,n]$, you can perform any of the following two operations for any times:

1.Choose $i,j \in [1,n],i\not = j$, swap $a_i,a_j$ costing $1$.

2.Choose $i,v \in [1,n]$, set $a_i = v$ costing $k$.

For example, if you perform operations of the first kind for $5$ times and perform operations of the second kind for $4$ times, then it will cost you $4 \times k + 5$.

Denote $cost_k(a)$ as the minimum total cost for the sequence $a$ with the parameter $k$. For each $k \in [0,2]$, print the mathematical expectation $E(cost_k(a))$ $mod$ $998244353 $.

Now, you need to answer the above question for each $n \in [1,N]$. That is to say, you should print $3 \times N$ values in total.

Input
One line contains only one integer $N$, $N \in [1,\ 5 \times 10^5]$.
Output
You should output $N$ lines with each containing $3$ values $E(cost_k(a))$ $mod$ $998244353 $, $\forall k \in [0,2]$ separated by two spaces.
SampleInput
example 1:
1

example 2:
2
SampleOutput
example 1:
0 0 0

example 2:
0 0 0
0 249561089 748683266
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: