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

建议使用的浏览器:

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

5184:Brackets

题目描述
We give the following inductive definition of a “regular brackets” sequence:
● the empty sequence is a regular brackets sequence,
● if s is a regular brackets sequence, then (s) are regular brackets sequences, and
● if a and b are regular brackets sequences, then ab is a regular brackets sequence.
● no other sequence is a regular brackets sequence

For instance, all of the following character sequences are regular brackets sequences:
(), (()), ()(), ()(())
while the following character sequences are not:
(, ), )(, ((), ((()

Now we want to construct a regular brackets sequence of length $n$, how many regular brackets sequences we can get when the front several brackets are given already.
输入解释
Multi test cases (about $2000$), every case occupies two lines.
The first line contains an integer $n$.
Then second line contains a string str which indicates the front several brackets.

Please process to the end of file.

[Technical Specification]
$1 \leq n \leq 1000000$
str contains only '(' and ')' and length of str is larger than 0 and no more than $n$.
输出解释
For each case,output answer % $1000000007$ in a single line.
输入样例
4
()
4
(
6
()
输出样例
1
2
2

提示
For the first case the only regular sequence is ()().
For the second case regular sequences are (()) and ()().
For the third case regular sequences are ()()() and ()(()).
来自杭电HDUOJ的附加信息
Recommend hujie

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

题目来源 BestCoder Round #32

源链接: HDU-5184

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

共提交 0

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