CF1920E.Counting Binary Strings

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

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 ss such that ss contains exactly nn good substrings and has no good substring of length strictly greater than kk. Note that substrings are differentiated by their location in the string, so if s=s = 1010 you should count both occurrences of 10.

†^\dagger A string aa is a substring of a string bb if aa can be obtained from bb 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.

帕特里克将一个二进制字符串的子串†^\dagger称为“好”的,当且仅当该子串中恰好包含一个 1。

请帮助帕特里克计算满足以下条件的二进制字符串 ss 的个数:

  • ss 中恰好包含 nn 个好子串;
  • ss 中不存在长度严格大于 kk 的好子串。

注意:子串由其在字符串中的位置区分。例如,若 $s = $ 1010,则应将两个 10 均计入(即分别对应位置 [0,1][0,1] 和 [2,3][2,3])。

†^\dagger 字符串 aa 是字符串 bb 的子串,当且仅当 aa 可通过从 bb 的开头删除若干(可能为零或全部)字符、并从 bb 的末尾删除若干(可能为零或全部)字符而得到。
‡^\ddagger 二进制字符串是仅由字符 0 和 1 组成的字符串。

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt (1≤t≤25001 \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 nn and kk (1≤n≤25001 \leq n \leq 2500, 1≤k≤n1 \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 nn over all test cases does not exceed 25002500.

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤25001 \leq t \leq 2500),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例仅一行,包含两个整数 nn 和 kk(1≤n≤25001 \leq n \leq 2500,1≤k≤n1 \leq k \leq n),分别表示所需“好子串”的数量以及“好子串”允许的最大长度。

保证所有测试用例中 nn 的总和不超过 25002500。

输出格式

For each test case, output a single integer — the number of binary strings ss such that ss contains exactly nn good substrings and has no good substring of length strictly greater than kk. Since this integer can be too large, output it modulo 998 244 353998\,244\,353.

对于每个测试用例,输出一个整数——满足以下条件的二进制字符串 ss 的个数:ss 恰好包含 nn 个“好”子串,且不包含长度严格大于 kk 的“好”子串。由于该整数可能过大,请将其对 998 244 353998\,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>12 \gt 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.

在第一个测试用例中,唯一合适的二进制字符串是 1。字符串 01 不合适,因为它包含长度为 2>12 \gt 1 的子串 01。

在第二个测试用例中,合适的二进制字符串有 011、110 和 111。

在第三个测试用例中,合适的二进制字符串有 101、0110、0111、1110 和 1111。

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

首页