#abc295f. F - substr = S
F - substr = S
Score : points
问题描述
你将得到一个由数字组成的字符串 ,以及对于 个测试用例的正整数 和 。请解决以下问题。
对于正整数 ,我们定义函数 为 的十进制表示(不含前导零)中等于 的连续子串的数量。
例如,如果 22
,则有 ,,,以及 。
求 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string consisting of digits and positive integers and for each of test cases. Solve the following problem.
For a positive integer , let us define as the number of contiguous substrings of the decimal representation of (without leading zeros) that equal .
For instance, if 22
, we have , , , and .
Find .
Constraints
- is a string consisting of digits whose length is between and , inclusive.
- and are integers satisfying .
Input
The input is given from Standard Input in the following format, where denotes the -th test case:
Each test case is in the following format:
Output
Print lines in total.
The -th line should contain an integer representing the answer to the -th test case.
Sample Input 1
6
22 23 234
0295 295 295
0 1 9999999999999999
2718 998244353 9982443530000000
869120 1234567890123456 2345678901234567
2023032520230325 1 9999999999999999
Sample Output 1
12
0
14888888888888889
12982260572545
10987664021
1
This input contains six test cases.
- In the first test case,
22
, , .- .
- .
- Thus, the answer is .
- In the second test case,
0295
, , .- Note that .
update @ 2024/3/10 12:16:41