Moo Decomposition
시간 제한2초메모리 제한2048 MB
M과 O로 이루어진 거대한 주기 문자열을 M 뒤에 O가 정확히 K개 오는 부분수열들로 분해하는 경우의 수를 10^9+7로 나눈 나머지를 구한다.
문제
You have a long string of Ms and Os and an integer . Count the number of ways of ways to decompose into subsequences such that each subsequence is MOOOO....O with exactly Os, modulo .
Since the string is very long, you are not given it explicitly. Instead, you are given an integer (), and a string of length (). The string is the concatenation of copies of the string .
입력
The first line contains , , and .
The second line contains the string of length . Every character is either an M or an O.
It is guaranteed that the number of decompositions of is nonzero.
출력
Output the number of decompositions of string , modulo .