测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A10681. Long number

编程题 普及/提高-

题目描述

Consider the following grammar:

- <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'

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

- <number> describes itself,
- <number>-<number> (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,
- <number>(<expression>) describes integer which is concatenation of <number> copies of integer described by <expression>,
- <expression>+<term> describes integer which is concatenation of integers described by <expression> and <term>.

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 $10^{9}+7$ .

输入格式

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

输出格式

Print single integer — the number described by the expression modulo $10^{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
上一题 去做题 下一题