luogu#P4916. [MtOI2018] 魔力环

    ID: 3933 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2018洛谷原创O2优化枚举Pólya 定理莫比乌斯反演

[MtOI2018] 魔力环

Background

wkr is an OIer from the City of Magic, and he likes collecting black and white magic beads.

Problem Description

wkr wants to obtain a ring made by stringing together nn magic beads. However, he is not interested in ordinary rings, so he proposes the following requirements:

  • wkr wants the ring to have exactly mm black magic beads and nmn - m white magic beads.
  • Since wkr believes black magic beads should not be too dense, he wants that on the ring there will not appear a consecutive segment of black magic beads whose length exceeds kk.

In wkr’s mind, only rings that satisfy the above requirements are wonderful.

However, such rings may not be unique. wkr wants to know how many different rings satisfy his requirements. But wkr does not like doing calculations, so he hopes the smart you can tell him the answer.

Here, we consider two rings to be different if and only if one ring cannot be obtained from the other by rotation only.

Since the answer may be too large, output the result modulo 998,244,353998, 244, 353.

Input Format

The input consists of 11 line with 33 non-negative integers n,m,kn, m, k, whose meanings are described above. Adjacent numbers are separated by a single space.

Output Format

Output 11 line with 11 integer, representing the number of rings that meet the requirements.

6 3 2

3

17 8 6

1421

50000 20000 1

683811528

Hint

Explanation of Sample 11

For rings made of 66 magic beads, with exactly 33 black magic beads and 33 white magic beads, and with no consecutive segment of black magic beads of length greater than 22, there are 33 different rings, as shown below.

The ring shown below does not meet wkr’s requirements, because in this ring there exists a consecutive segment of black magic beads whose length exceeds 22.

Subtasks

All testdata satisfy 1n,k1051 \leq n, k \leq 10^5, 0m1050 \leq m \leq 10^5, and mnm \leq n.

This problem uses bundled tests. There are 77 subtasks, and the score and limits of each subtask are as follows:

  • Subtask 1 (3 points): m=0m = 0.
  • Subtask 2 (5 points): n4n \leq 4.
  • Subtask 3 (8 points): n18n \leq 18.
  • Subtask 4 (7 points): m=2m = 2.
  • Subtask 5 (19 points): k=1k = 1.
  • Subtask 6 (27 points): gcd(n,m)2\gcd(n,m) \leq 2.
  • Subtask 7 (31 points): No special restrictions.

Source

MtOI2018 迷途の家の水题大赛 T6

Problem setter: Imagine

72679

Translated by ChatGPT 5