#P8941. [DTOI 2023] D. Goodbye 2022

[DTOI 2023] D. Goodbye 2022

Background

I announce with fireworks, say goodbye with a wave, and give thanks with a bow. Everything in the past is already past. From now on, I will walk the road ahead in a relaxed way, in a happy way. My steps are like time that never stops. Next year, we will meet again.

Problem Description

This problem background has nothing to do with luanmenglei.

Given n,k,pn, k, p, find how many ordered pp-tuples (a1,a2,⋯ ,ap)(a_1, a_2, \cdots, a_p) satisfy:

  • ∀i∈[1,p]\forall i \in [1, p], ai∈[1,n]a_i \in [1, n].
  • ∀i∈[1,p)\forall i \in [1, p), popcount⁡(ai⊕ai+1)=k\operatorname{popcount}(a_i \oplus a_{i+1}) = k.
  • ∀i,j∈[1,p],i≠j\forall i, j \in [1, p], i \neq j, ai≠aja_i \neq a_j.

Output the answer modulo 998244353998244353.


  • popcount⁡(x)\operatorname{popcount}(x) denotes the number of 11 bits in the binary representation of xx.
  • ⊕\oplus denotes the bitwise XOR operation.
  • Two ordered pp-tuples (a1,a2,…,ap)(a_1, a_2, \dots, a_p) and (b1,b2,…,bp)(b_1, b_2, \dots, b_p) are different if and only if there exists i∈[1,p]i \in [1, p] such that ai≠bia_i \neq b_i.

Input Format

One line with three positive integers n,k,pn, k, p.

Output Format

One line with one integer, representing the answer.

5 1 2
8
6 1 3
12
7 1 4
48
8 3 5
6
9 2 5
72
114 3 3
106624
514 3 4
296097032
1000 7 5
569405945
1000 7 1
1000

Hint

For all testdata, it is guaranteed that 1≤n≤10001 \leq n \leq 1000, 1≤k≤⌊log⁡2n⌋1 \leq k \leq \lfloor \log_2 n \rfloor, and 1≤p≤51 \leq p \leq 5.

The specific limits for each test point are shown in the table below:

Test Point ID n≤n \leq p=p =
11 10001000 11
2∼32 \sim 3 22
4∼54 \sim 5 300300 33
6∼126 \sim 12 10001000
13∼1513 \sim 15 44
16∼2116 \sim 21 300300 55
22∼2522 \sim 25 10001000

Translated by ChatGPT 5