CF756F.Long number

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Consider the following grammar:

  • ::= | '+'
  • ::= | '-' | '(' ')'
  • ::= <pos_digit> |
  • ::= '0' | <pos_digit>
  • <pos_digit> ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

This grammar describes a number in decimal system using the following rules:

  • describes itself,
  • - (l-r, l ≤ r) describes integer which is concatenation of all integers from l to r, written without leading zeros. For example, 8-11 describes 891011,
  • () describes integer which is concatenation of copies of integer described by ,
  • + describes integer which is concatenation of integers described by and .

For example, 2(2-4+1)+2(2(17)) describes the integer 2341234117171717.

You are given an expression in the given grammar. Print the integer described by it modulo 109 + 7.

考虑如下文法:

  • <expression> ::= <term> | <expression> '+' <term>
  • <term> ::= <number> | <number> '-' <number> | <number> '(' <expression> ')'
  • <number> ::= <pos_digit> | <number> <digit>
  • <digit> ::= '0' | <pos_digit>
  • <pos_digit> ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

该文法用如下规则描述一个十进制整数:

  • <number> 本身即表示其对应的整数;
  • <number>-<number>(记为 l-r,其中 l≤rl \le r)表示将从 ll 到 rr(含端点)的所有整数依次拼接所形成的整数(拼接时不带前导零)。例如,8-11 表示整数 891011;
  • <number>(<expression>) 表示将 <expression> 所描述的整数重复 <number> 次后拼接所形成的整数;
  • <expression>+<term> 表示将 <expression> 和 <term> 各自所描述的整数依次拼接所形成的整数。

例如,2(2-4+1)+2(2(17)) 描述的整数为 2341234117171717。

给定符合上述文法的一个表达式,请输出它所描述的整数对 109+710^9 + 7 取模的结果。

输入格式

The only line contains a non-empty string at most 105 characters long which is valid according to the given grammar. In particular, it means that in terms l-r l ≤ r holds.

唯一一行包含一个非空字符串,长度最多为 10510^5,且该字符串符合给定的语法规则。特别地,这意味着对于所有形如 l-r 的项,均有 l≤rl \le r 成立。

输出格式

Print single integer — the number described by the expression modulo 109 + 7.

输出一个整数——即该表达式所表示的数对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

    8-11

    输出#1

    891011
  • 输入#2

    2(2-4+1)+2(2(17))

    输出#2

    100783079
  • 输入#3

    1234-5678

    输出#3

    745428774
  • 输入#4

    1+2+3+4-5+6+7-9

    输出#4

    123456789

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

首页