Toggle navigation
HUSTOJ
F.A.Qs
ProblemSet
Source/Category
Status
Ranklist
Contest
Login
Problem1038-- V1038 添加括号
1038: V1038 添加括号
Time Limit:
1
Sec
Memory Limit:
128 MB
Submit:
0
Solved:
0
[
Status
] [
Submit
] [Creator:
]
Description
现在要添上n-1对括号,加法运算依括号顺序进行,得到n-1个中间和,求出使中间和之和最小的添括号方法。
Input
共两行。 第一行,为整数n。(1< =n< =20) 第二行,为a(1),a(2),...,a(n)这n个正整数,每个数字不超过100。
Output
输出3行。 第一行,为添加括号的方法。 第二行,为最终的中间和之和。 第三行,为n-1个中间和,按照从里到外,从左到右的顺序输出。
Sample Input
Copy
4 4 1 2 3
Sample Output
Copy
(4+((1+2)+3)) 19 3 6 10
Source/Category
MaoLaoda