CF1920E.Counting Binary Strings

普及/提高-

通过率:0%

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.

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt ( 1t25001 \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 ( 1n25001 \leq n \leq 2500 , 1kn1 \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 .

输出格式

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 998244353998\,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 > 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.

首页