F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Expression

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1424    Accepted Submission(s): 871


Problem Description
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$.
 

Input
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.
 

Output
For each test case print the answer modulo $10^9+7$.
 

Sample Input
3 3 2 1 -+ 5 1 4 6 8 3 +*-*
 

Sample Output
2 999999689
 

Hint
Two numbers are considered different when they are in different positions.
 

Author
xudyh
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 11:01:57, Gzip enabled