Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 点
問題文
を正整数とします。
長さ の文字列 が与えられます。
は < と > からなります。
を並べ替えた順列 であって、次の条件を満たすものは何通りでしょうか? で割った余りを求めてください。
- 各 () について、 の 文字目が
<の場合は であり、 の 文字目が>の場合は である。
制約
- は整数である。
- は長さ の文字列である。
- は
<と>からなる。
入力
入力は以下の形式で標準入力から与えられる。
出力
条件を満たす順列は何通りか? で割った余りを出力せよ。
入力例 1Copy
4 <><
出力例 1Copy
5
条件を満たす順列は次の 通りです。
入力例 2Copy
5 <<<<
出力例 2Copy
1
条件を満たす順列は次の 通りです。
入力例 3Copy
20 >>>><>>><>><>>><<>>
出力例 3Copy
217136290
答えを で割った余りを出力することを忘れずに。
Score : points
Problem Statement
Let be a positive integer.
You are given a string of length , consisting of < and >.
Find the number of permutations of that satisfy the following condition, modulo :
- For each (), if the -th character in is
<, and if the -th character in is>.
Constraints
- is an integer.
- is a string of length .
- consists of
<and>.
Input
Input is given from Standard Input in the following format:
Output
Print the number of permutations that satisfy the condition, modulo .
Sample Input 1Copy
4 <><
Sample Output 1Copy
5
There are five permutations that satisfy the condition, as follows:
Sample Input 2Copy
5 <<<<
Sample Output 2Copy
1
There is one permutation that satisfies the condition, as follows:
Sample Input 3Copy
20 >>>><>>><>><>>><<>>
Sample Output 3Copy
217136290
Be sure to print the number modulo .