F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Array Repairing

Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 95    Accepted Submission(s): 41


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.
 

Sample Input
example 1: 1 example 2: 2
 

Sample Output
example 1: 0 0 0 example 2: 0 0 0 0 249561089 748683266
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 18:33:52, Gzip enabled