#P1008. 4. noip模拟测验(四)-解码

4. noip模拟测验(四)-解码

Long number

题面翻译

考虑下面的算法(设 A,B 为自然数):

  • A :表示 A 本身。
  • A-B :不间断地输出 A 到 B 之间的数( ABA\le B ),例如 8-11,表示 891011。
  • A(B):把数字 B 重复 A 遍。
  • A+B:连接数字 A 和 B。

举个例子,2(2-4+1)+2(2(17)) 表示的数是 2341234117171717。
现在请你输出在如上规则下的数对 109+710^9+7 取余的结果(输入的长度不超过 10510^5)。

题目描述

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 l<=r ) describes integer which is concatenation of all integers from l l to r 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 10^{9}+7 .

输入格式

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

输出格式

Print single integer — the number described by the expression modulo 109+7 10^{9}+7 .

样例 #1

样例输入 #1

8-11

样例输出 #1

891011

样例 #2

样例输入 #2

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

样例输出 #2

100783079

样例 #3

样例输入 #3

1234-5678

样例输出 #3

745428774

样例 #4

样例输入 #4

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

样例输出 #4

123456789