?
既求从点(0,0)只能向上或者向右并且不穿越y=x到达点(a,b)有多少总走法...
有公式: C(a+b,min(a,b))-C(a+b,min(a,b)-1) ///
?
?
?
Brackets
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 506 Accepted Submission(s): 120
Problem Description 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
Input Multi test cases (about
The first line contains an integer
Then second line contains a string str which indicates the front several brackets.
Please process to the end of file.
[Technical Specification]
str contains only '(' and ')' and length of str is larger than 0 and no more than
Output For each case,output answer %
Sample Input
4 () 4 ( 6 ()
Sample Output
1 2 2 HintFor the first case the only regular sequence is ()(). For the second case regular sequences are (()) and ()(). For the third case regular sequences are ()()() and ()(()).
?
?
?
/* *********************************************** Author :CKboss Created Time :2015年03月18日 星期三 20时10分21秒 File Name :HDOJ5184.cpp ************************************************ */ #include#include #include #include #include #include #include #include #include #include #include