A16379 | Counting Binary Strings
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Patrick calls a substring $^\dagger$ of a binary string $^\ddagger$ good if this substring contains exactly one 1.
Help Patrick count the number of binary strings $s$ such that $s$ contains exactly $n$ good substrings and has no good substring of length strictly greater than $k$ . Note that substrings are differentiated by their location in the string, so if $s =$ 1010 you should count both occurrences of 10.
$^\dagger$ A string $a$ is a substring of a string $b$ if $a$ can be obtained from $b$ by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
$^\ddagger$ A binary string is a string that only contains the characters 0 and 1.
Help Patrick count the number of binary strings $s$ such that $s$ contains exactly $n$ good substrings and has no good substring of length strictly greater than $k$ . Note that substrings are differentiated by their location in the string, so if $s =$ 1010 you should count both occurrences of 10.
$^\dagger$ A string $a$ is a substring of a string $b$ if $a$ can be obtained from $b$ by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
$^\ddagger$ A binary string is a string that only contains the characters 0 and 1.
输入格式
Each test consists of multiple test cases. The first line contains a single integer $t$ ( $1 \leq t \leq 2500$ ) — the number of test cases. The description of the test cases follows.
The only line of each test case contains two integers $n$ and $k$ ( $1 \leq n \leq 2500$ , $1 \leq k \leq n$ ) — the number of required good substrings and the maximum allowed length of a good substring.
It is guaranteed that the sum of $n$ over all test cases does not exceed $2500$ .
The only line of each test case contains two integers $n$ and $k$ ( $1 \leq n \leq 2500$ , $1 \leq k \leq n$ ) — the number of required good substrings and the maximum allowed length of a good substring.
It is guaranteed that the sum of $n$ over all test cases does not exceed $2500$ .
输出格式
For each test case, output a single integer — the number of binary strings $s$ such that $s$ contains exactly $n$ good substrings and has no good substring of length strictly greater than $k$ . Since this integer can be too large, output it modulo $998\,244\,353$ .
输入输出样例
输入 #1
6 1 1 3 2 4 2 5 4 6 2 2450 2391
输出 #1
1 3 5 12 9 259280854
In the first test case, the only suitable binary string is 1. String 01 is not suitable because it contains a substring 01 with length $2 > 1$ .
In the second test case, suitable binary strings are 011, 110 and 111.
In the third test case, suitable binary strings are 101, 0110, 0111, 1110, and 1111.
In the second test case, suitable binary strings are 011, 110 and 111.
In the third test case, suitable binary strings are 101, 0110, 0111, 1110, and 1111.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted