Problem:
Score : 700 points

Problem Statement

Takahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.
For each i=2,3,...,2K, find the following value modulo 998244353:

The number of combinations of N sides shown by the dice such that the sum of no two different sides is i.

Note that the dice are NOT distinguishable, that is, two combinations are considered different when there exists an integer k such that the number of dice showing k is different in those two.

Constraints

1 \leq K \leq 2000

2 \leq N \leq 2000

K and N are integers.

Input

Input is given from Standard Input in the following format:

K N

Output

Print 2K-1 integers. The t-th of them (1\leq t\leq 2K-1) should be the answer for i=t+1.

Sample Input 1

3 3

Sample Output 1

7
7
4
7
7

For i=2, the combinations (1,2,2),(1,2,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.

For i=3, the combinations (1,1,1),(1,1,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.

For i=4, the combinations (1,1,1),(1,1,2),(2,3,3),(3,3,3) satisfy the condition, so the answer is 4.

Sample Input 2

4 5

Sample Output 2

36
36
20
20
20
36
36

Sample Input 3

6 1000

Sample Output 3

149393349
149393349
668669001
668669001
4000002
4000002
4000002
668669001
668669001
149393349
149393349

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let k: i64 = input();
    let n: i64 = input();
    const MOD: i64 = 998244353;

    let comb = Combination::new(n + k, MOD);
    let mut p2 = vec![0; k as usize + 1];
    p2[0] = 1;
    for i in 0..k as usize {
        p2[i + 1] = 2 * p2[i] % MOD;
    }

    let mut ans = vec![0; 2 * k as usize + 1];
    for i in 2..2 * k + 1 {
        let mut p = 0;
        for j in 1..k {
            if 0 < i - j && i - j <= k && j < i - j {
                p += 1;
            }
        }
        let mut r = k - 2 * p;
        if i % 2 == 0 {
            r = k - 2 * p - 1;
        }

        let mut temp = 0;
        for q in 0..p + 1 {
            if i % 2 == 0 {
                temp += p2[q as usize] * comb.combination(p, q) % MOD
                    * comb.combination(n - q + q + r - 1, n - q)
                    % MOD;
                temp += p2[q as usize] * comb.combination(p, q) % MOD
                    * comb.combination(n - 1 - q + q + r - 1, n - 1 - q)
                    % MOD;
            } else {
                temp += p2[q as usize] * comb.combination(p, q) % MOD
                    * comb.combination(n - q + q + r - 1, n - q)
                    % MOD;
            }
            temp %= MOD;
        }
        ans[i as usize] = temp;
    }

    with_stdout_lock(|mut w| {
        for i in 2..2 * k as usize + 1 {
            writeln!(w, "{}", ans[i]).unwrap();
        }
    });
}

struct Combination {
    fact: Vec<i64>,
    ifact: Vec<i64>,
    modulus: i64,
}
impl Combination {
    fn new(n: i64, m: i64) -> Combination {
        let n = n as usize;
        let mut fact = vec![0; n + 1];
        let mut ifact = vec![0; n + 1];
        fact[0] = 1;
        for i in 1..n + 1 {
            fact[i] = fact[i - 1] * i as i64 % m;
        }
        ifact[n] = Combination::pow(fact[n], m - 2, m);
        for i in (1..n + 1).rev() {
            ifact[i - 1] = ifact[i] * i as i64 % m;
        }
        Combination {
            fact: fact,
            ifact: ifact,
            modulus: m,
        }
    }
    fn pow(x: i64, p: i64, m: i64) -> i64 {
        if p == 0 {
            1
        } else if p % 2 == 0 {
            let t = Combination::pow(x, p / 2, m);
            t * t % m
        } else {
            let t = Combination::pow(x, p / 2, m);
            t * t % m * x % m
        }
    }
    fn combination(&self, n: i64, k: i64) -> i64 {
        if n < 0 || k < 0 || n < k {
            0
        } else {
            let (n, k) = (n as usize, k as usize);
            self.fact[n] * self.ifact[k] % self.modulus * self.ifact[n - k] % self.modulus
        }
    }
}