#abc338g. G - evall
G - evall
Score: points
问题描述
给定一个字符串 ,其每个字符为 123456789+*
中的一个,并且 的首尾字符均为数字。在 中不存在相邻的非数字字符。
对于一对整数 (满足 ),我们定义 如下:
- 如果 的第 个和第 个字符都是数字,则 是将从第 个到第 个(包含)字符的 当作常规算术表达式求值的结果(其中
*
表示乘法)。例如,如果1+2*151
,则 。 - 否则, 等于零。
请计算 ${\displaystyle \sum_{i=1}^{|S|} \sum_{j=i}^{|S|} \mathrm{eval}(S_{i..j})}$ 并对 取模后的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string . Each character of is one of 123456789+*
, and the first and last characters of are digits. There are no adjacent non-digit characters in .
For a pair of integers (), we define as follows:
- If both the -th and -th characters of are digits, then is the result of evaluating the -th to the -th characters (inclusive) of as a usual arithmetic expression (where
*
represents multiplication). For example, if1+2*151
, then . - Otherwise, is zero.
Find ${\displaystyle \sum_{i=1}^{|S|} \sum_{j=i}^{|S|} \mathrm{eval}(S_{i..j})}$, modulo .
Constraints
- Each character of is one of
123456789+*
. - The first and last characters of are digits.
- There are no adjacent non-digit characters in .
Input
The input is given from Standard Input in the following format:
Output
Print ${\displaystyle \sum_{i=1}^{|S|} \sum_{j=i}^{|S|} \mathrm{eval}(S_{i..j})}$, modulo .
Sample Input 1
1+2*34
Sample Output 1
197
The cases where is not zero are as follows:
The sum of these is .
Sample Input 2
338*3338*33338*333338+3333338*33333338+333333338
Sample Output 2
527930018
update @ 2024/3/10 01:30:32