当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5396:Expression

题目描述
Teacher Mai has $n$ numbers $a_1,a_2,\cdots,a_n$and $n-1$ operators("+", "-" or "*")$op_1,op_2,\cdots,op_{n-1}$, which are arranged in the form $a_1~op_1~a_2~op_2~a_3~\cdots~a_n$.

He wants to erase numbers one by one. In $i$-th round, there are $n+1-i$ numbers remained. He can erase two adjacent numbers and the operator between them, and then put a new number (derived from this one operation) in this position. After $n-1$ rounds, there is the only one number remained. The result of this sequence of operations is the last number remained.


He wants to know the sum of results of all different sequences of operations. Two sequences of operations are considered different if and only if in one round he chooses different numbers.

For example, a possible sequence of operations for "$1+4*6-8*3$" is $1+4*6-8*3\to 1+4*(-2)*3\to 1+(-8)*3\to (-7)*3\to -21$.
输入解释
There are multiple test cases.

For each test case, the first line contains one number $n(2\leq n\leq 100)$.

The second line contains $n$ integers $a_1,a_2,\cdots,a_n(0\leq a_i\leq 10^9)$.

The third line contains a string with length $n-1$ consisting "+","-" and "*", which represents the operator sequence.
输出解释
For each test case print the answer modulo $10^9+7$.
输入样例
3
3 2 1
-+
5
1 4 6 8 3
+*-*
输出样例
2
999999689
提示
 Two numbers are considered different when they are in different positions.
来自杭电HDUOJ的附加信息
Author xudyh
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5396

最后修改于 2020-10-25T23:22:19+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)