A15341 | Chip Move
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There is a chip on the coordinate line. Initially, the chip is located at the point $0$ . 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 $k$ , the length of the second move — by $k+1$ , the third — by $k+2$ , and so on.
For example, if $k=2$ , then the sequence of moves may look like this: $0 \rightarrow 4 \rightarrow 7 \rightarrow 19 \rightarrow 44$ , because $4 - 0 = 4$ is divisible by $2 = k$ , $7 - 4 = 3$ is divisible by $3 = k + 1$ , $19 - 7 = 12$ is divisible by $4 = k + 2$ , $44 - 19 = 25$ is divisible by $5 = k + 3$ .
You are given two positive integers $n$ and $k$ . Your task is to count the number of ways to reach the point $x$ , starting from $0$ , for every $x \in [1, n]$ . The number of ways can be very large, so print it modulo $998244353$ . Two ways are considered different if they differ as sets of visited positions.
For example, if $k=2$ , then the sequence of moves may look like this: $0 \rightarrow 4 \rightarrow 7 \rightarrow 19 \rightarrow 44$ , because $4 - 0 = 4$ is divisible by $2 = k$ , $7 - 4 = 3$ is divisible by $3 = k + 1$ , $19 - 7 = 12$ is divisible by $4 = k + 2$ , $44 - 19 = 25$ is divisible by $5 = k + 3$ .
You are given two positive integers $n$ and $k$ . Your task is to count the number of ways to reach the point $x$ , starting from $0$ , for every $x \in [1, n]$ . The number of ways can be very large, so print it modulo $998244353$ . Two ways are considered different if they differ as sets of visited positions.
输入格式
The first (and only) line of the input contains two integers $n$ and $k$ ( $1 \le k \le n \le 2 \cdot 10^5$ ).
输出格式
Print $n$ integers — the number of ways to reach the point $x$ , starting from $0$ , for every $x \in [1, n]$ , taken modulo $998244353$ .
输入输出样例
输入 #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 $1$ : $[0, 1]$ ;
Ways to reach the point $2$ : $[0, 2]$ ;
Ways to reach the point $3$ : $[0, 1, 3]$ , $[0, 3]$ ;
Ways to reach the point $4$ : $[0, 2, 4]$ , $[0, 4]$ ;
Ways to reach the point $5$ : $[0, 1, 5]$ , $[0, 3, 5]$ , $[0, 5]$ ;
Ways to reach the point $6$ : $[0, 1, 3, 6]$ , $[0, 2, 6]$ , $[0, 4, 6]$ , $[0, 6]$ ;
Ways to reach the point $7$ : $[0, 2, 4, 7]$ , $[0, 1, 7]$ , $[0, 3, 7]$ , $[0, 5, 7]$ , $[0, 7]$ ;
Ways to reach the point $8$ : $[0, 3, 5, 8]$ , $[0, 1, 5, 8]$ , $[0, 2, 8]$ , $[0, 4, 8]$ , $[0, 6, 8]$ , $[0, 8]$ .
Ways to reach the point $1$ : $[0, 1]$ ;
Ways to reach the point $2$ : $[0, 2]$ ;
Ways to reach the point $3$ : $[0, 1, 3]$ , $[0, 3]$ ;
Ways to reach the point $4$ : $[0, 2, 4]$ , $[0, 4]$ ;
Ways to reach the point $5$ : $[0, 1, 5]$ , $[0, 3, 5]$ , $[0, 5]$ ;
Ways to reach the point $6$ : $[0, 1, 3, 6]$ , $[0, 2, 6]$ , $[0, 4, 6]$ , $[0, 6]$ ;
Ways to reach the point $7$ : $[0, 2, 4, 7]$ , $[0, 1, 7]$ , $[0, 3, 7]$ , $[0, 5, 7]$ , $[0, 7]$ ;
Ways to reach the point $8$ : $[0, 3, 5, 8]$ , $[0, 1, 5, 8]$ , $[0, 2, 8]$ , $[0, 4, 8]$ , $[0, 6, 8]$ , $[0, 8]$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted