CF1051E.Vasya and Big Integers

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Vasya owns three big integers — a,l,ra, l, r. Let's define a partition of xx such a sequence of strings s1,s2,…,sks_1, s_2, \dots, s_k that s1+s2+⋯+sk=xs_1 + s_2 + \dots + s_k = x, where ++ is a concatanation of strings. sis_i is the ii-th element of the partition. For example, number 1234512345 has the following partitions: ["1", "2", "3", "4", "5"], ["123", "4", "5"], ["1", "2345"], ["12345"] and lots of others.

Let's call some partition of aa beautiful if each of its elements contains no leading zeros.

Vasya want to know the number of beautiful partitions of number aa, which has each of sis_i satisfy the condition l≤si≤rl \le s_i \le r. Note that the comparison is the integer comparison, not the string one.

Help Vasya to count the amount of partitions of number aa such that they match all the given requirements. The result can be rather big, so print it modulo 998244353998244353.

瓦西里拥有三个大整数:aa、ll 和 rr。我们定义 xx 的一个划分为一个字符串序列 s1,s2,…,sks_1, s_2, \dots, s_k,使得 s1+s2+⋯+sk=xs_1 + s_2 + \dots + s_k = x,其中 ++ 表示字符串拼接运算,sis_i 是该划分的第 ii 个元素。例如,数字 1234512345 具有如下划分:["1", "2", "3", "4", "5"]、["123", "4", "5"]、["1", "2345"]、["12345"],以及许多其它划分。

若某个 aa 的划分中每个元素均不含前导零,则称其为优美的划分。

瓦西里想知道:满足如下条件的 aa 的优美划分的数量是多少?即对划分中的每个元素 sis_i,均满足 l≤si≤rl \le s_i \le r。注意,此处的比较是整数比较,而非字符串字典序比较。

请帮助瓦西里计算满足所有给定条件的 aa 的划分数量。结果可能非常大,请对 998244353998244353 取模后输出。

输入格式

The first line contains a single integer a (1≤a≤101000000)a~(1 \le a \le 10^{1000000}).

The second line contains a single integer l (0≤l≤101000000)l~(0 \le l \le 10^{1000000}).

The third line contains a single integer r (0≤r≤101000000)r~(0 \le r \le 10^{1000000}).

It is guaranteed that l≤rl \le r.

It is also guaranteed that numbers a,l,ra, l, r contain no leading zeros.

第一行包含一个整数 a (1≤a≤101000000)a~(1 \le a \le 10^{1000000})。

第二行包含一个整数 l (0≤l≤101000000)l~(0 \le l \le 10^{1000000})。

第三行包含一个整数 r (0≤r≤101000000)r~(0 \le r \le 10^{1000000})。

保证 l≤rl \le r。

同时保证数字 a,l,ra, l, r 均不含前导零。

输出格式

Print a single integer — the amount of partitions of number aa such that they match all the given requirements modulo 998244353998244353.

输出一个整数——满足所有给定要求的数字 aa 的划分方案数,对 998244353998244353 取模。

输入输出样例

  • 输入#1

    135
    1
    15

    输出#1

    2
  • 输入#2

    10000
    0
    9

    输出#2

    1

说明/提示

In the first test case, there are two good partitions 13+513+5 and 1+3+51+3+5.

In the second test case, there is one good partition 1+0+0+0+01+0+0+0+0.

在第一个测试用例中,存在两个好的划分:13+513+5 和 1+3+51+3+5。

在第二个测试用例中,存在一个好的划分:1+0+0+0+01+0+0+0+0。

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

首页