CF1716D.Chip Move

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a chip on the coordinate line. Initially, the chip is located at the point 00. You can perform any number of moves; each move increases the coordinate of the chip by some positive integer (which is called the length of the move). The length of the first move you make should be divisible by kk, the length of the second move — by k+1k+1, the third — by k+2k+2, and so on.

For example, if k=2k=2, then the sequence of moves may look like this: 0→4→7→19→440 \rightarrow 4 \rightarrow 7 \rightarrow 19 \rightarrow 44, because 4−0=44 - 0 = 4 is divisible by 2=k2 = k, 7−4=37 - 4 = 3 is divisible by 3=k+13 = k + 1, 19−7=1219 - 7 = 12 is divisible by 4=k+24 = k + 2, 44−19=2544 - 19 = 25 is divisible by 5=k+35 = k + 3.

You are given two positive integers nn and kk. Your task is to count the number of ways to reach the point xx, starting from 00, for every x∈[1,n]x \in [1, n]. The number of ways can be very large, so print it modulo 998244353998244353. Two ways are considered different if they differ as sets of visited positions.

数轴上有一个芯片。初始时,芯片位于坐标 00 处。你可以执行任意次数的移动;每次移动将芯片的坐标增加某个正整数(称为该次移动的长度)。第一次移动的长度必须能被 kk 整除,第二次移动的长度必须能被 k+1k+1 整除,第三次移动的长度必须能被 k+2k+2 整除,依此类推。

例如,若 k=2k=2,则一次可能的移动序列为:0→4→7→19→440 \rightarrow 4 \rightarrow 7 \rightarrow 19 \rightarrow 44,因为 4−0=44 - 0 = 4 可被 2=k2 = k 整除,7−4=37 - 4 = 3 可被 3=k+13 = k + 1 整除,19−7=1219 - 7 = 12 可被 4=k+24 = k + 2 整除,44−19=2544 - 19 = 25 可被 5=k+35 = k + 3 整除。

给定两个正整数 nn 和 kk。你的任务是:对每个 x∈[1,n]x \in [1, n],计算从 00 出发恰好到达点 xx 的方案数。答案可能非常大,请对 998244353998244353 取模后输出。若两种方案所经过的位置集合不同,则视为不同的方案。

输入格式

The first (and only) line of the input contains two integers nn and kk (1≤k≤n≤2⋅1051 \le k \le n \le 2 \cdot 10^5).

输入的第一行(也是唯一一行)包含两个整数 nn 和 kk(1≤k≤n≤2⋅1051 \le k \le n \le 2 \cdot 10^5)。

输出格式

Print nn integers — the number of ways to reach the point xx, starting from 00, for every x∈[1,n]x \in [1, n], taken modulo 998244353998244353.

输出 nn 个整数——对每个 x∈[1,n]x \in [1, n],从 00 出发到达点 xx 的方案数(对 998244353998244353 取模)。

输入输出样例

  • 输入#1

    8 1

    输出#1

    1 1 2 2 3 4 5 6
  • 输入#2

    10 2

    输出#2

    0 1 0 1 1 1 1 2 2 2

说明/提示

Let's look at the first example:

Ways to reach the point 11: [0,1][0, 1];

Ways to reach the point 22: [0,2][0, 2];

Ways to reach the point 33: [0,1,3][0, 1, 3], [0,3][0, 3];

Ways to reach the point 44: [0,2,4][0, 2, 4], [0,4][0, 4];

Ways to reach the point 55: [0,1,5][0, 1, 5], [0,3,5][0, 3, 5], [0,5][0, 5];

Ways to reach the point 66: [0,1,3,6][0, 1, 3, 6], [0,2,6][0, 2, 6], [0,4,6][0, 4, 6], [0,6][0, 6];

Ways to reach the point 77: [0,2,4,7][0, 2, 4, 7], [0,1,7][0, 1, 7], [0,3,7][0, 3, 7], [0,5,7][0, 5, 7], [0,7][0, 7];

Ways to reach the point 88: [0,3,5,8][0, 3, 5, 8], [0,1,5,8][0, 1, 5, 8], [0,2,8][0, 2, 8], [0,4,8][0, 4, 8], [0,6,8][0, 6, 8], [0,8][0, 8].

我们来看第一个例子:

到达点 11 的方法:[0,1][0, 1];

到达点 22 的方法:[0,2][0, 2];

到达点 33 的方法:[0,1,3][0, 1, 3]、[0,3][0, 3];

到达点 44 的方法:[0,2,4][0, 2, 4]、[0,4][0, 4];

到达点 55 的方法:[0,1,5][0, 1, 5]、[0,3,5][0, 3, 5]、[0,5][0, 5];

到达点 66 的方法:[0,1,3,6][0, 1, 3, 6]、[0,2,6][0, 2, 6]、[0,4,6][0, 4, 6]、[0,6][0, 6];

到达点 77 的方法:[0,2,4,7][0, 2, 4, 7]、[0,1,7][0, 1, 7]、[0,3,7][0, 3, 7]、[0,5,7][0, 5, 7]、[0,7][0, 7];

到达点 88 的方法:[0,3,5,8][0, 3, 5, 8]、[0,1,5,8][0, 1, 5, 8]、[0,2,8][0, 2, 8]、[0,4,8][0, 4, 8]、[0,6,8][0, 6, 8]、[0,8][0, 8]。

输入解题思路,AI测评打分。不知道怎么写?

首页