Logo
(追記) (追記ここまで)

33763번 - Moo Decomposition 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB88484058.824%

문제

You have a long string $S$ of Ms and Os and an integer $K \geq 1$. Count the number of ways of ways to decompose $S$ into subsequences such that each subsequence is MOOOO....O with exactly $K$ Os, modulo 10ドル^9+7$.

Since the string is very long, you are not given it explicitly. Instead, you are given an integer $L$ (1ドル \leq L \leq 10^{18}$), and a string $T$ of length $N$ (1ドル \leq N \leq 10^6$). The string $S$ is the concatenation of $L$ copies of the string $T$.

입력

The first line contains $K,ドル $N,ドル and $L$.

The second line contains the string $T$ of length $N$. Every character is either an M or an O.

It is guaranteed that the number of decompositions of $S$ is nonzero.

출력

Output the number of decompositions of string $S,ドル modulo 10ドル^9+7$.

제한

예제 입력 1

2 6 1
MOOMOO

예제 출력 1

1

The only way to decompose $S$ into MOOs is to let the first three characters form a MOO and the last three characters form another MOO.

예제 입력 2

2 6 1
MMOOOO

예제 출력 2

6

There are six distinct ways to decompose the string into subsequences (uppercase letters form one MOO, lowercase letters form another):

  • MmOOoo
  • MmOoOo
  • MmOooO
  • MmoOOo
  • MmoOoO
  • MmooOO

예제 입력 3

1 4 2
MMOO

예제 출력 3

4

예제 입력 4

1 4 100
MMOO

예제 출력 4

976371285

Make sure to take the answer modulo 10ドル^9+7$.

힌트

출처

Olympiad > USA Computing Olympiad > 2024-2025 Season > USACO 2025 US Open Contest > Gold 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /