Expression

TimeLimit: 2000/1000 MS (Java/Others)  MemoryLimit: 65536/65536 K (Java/Others)
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Teacher Mai has numbers and operators("+", "-" or "*"), which are arranged in the form .

He wants to erase numbers one by one. In -th round, there are 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 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 "" is .
Input
There are multiple test cases.

For each test case, the first line contains one number n(2<= n<= 100).

The second line contains n integers a1,a2,⋯,an(0≤ai≤10^9).

The third line contains a string with length n-1 consisting "+","-" and "*", which represents the operator sequence.
Output
For each test case print the answer modulo 10^9+7.
SampleInput
3
3 2 1
-+
5
1 4 6 8 3
+*-*
SampleOutput
2
999999689
Hint
Two numbers are considered different when they are in different positions.
Submit
题目统计信息详细
总AC数4
通过人数4
尝试人数6
总提交量10
AC率40.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: