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

Set2

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 396    Accepted Submission(s): 135


Problem Description
You are given a set $S=\{1..n\}$. You have to do the following operations until there are no more than $k$ elements left in the $S$:

Firstly, delete the smallest element of $S$, and then randomly delete another $k$ elements one by one from the elements left in $S$ in equal probability.

Note that the order of another deleted $k$ elements matters. That is to say, you delete $p$ after $q$ or delete $q$ after $p$, which are different ways.

For each $i \in [1,n]$, determine the probability of $i$ being left in the $S$.

It can be shown that the answers can be represented by $\frac{P}{Q}$, where $P$ and $Q$ are coprime integers, and print the value of $P \times Q^{-1} \ mod $ $\space 998244353$.
 

Input
The first line contains the only integer $T(T \in [1,40])$ denoting the number of test cases.

For each test case:

The first line contains two integers $n$ and $k$.

It guarantees that: $n \in [1,5000] ,\ \sum n \in [1,3 \times 10^4],\ k \in [1,5000].$
 

Output
For each test case, you should output $n$ integers, the $i$-th of them means the probability of $i$ being left in the $S$.
 

Sample Input
1 5 2
 

Sample Output
0 499122177 499122177 499122177 499122177
 

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:43:26, Gzip enabled