QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20911. פירוק Moo

Statistics

יש מחרוזת ארוכה $S$ של M ו-O ושלם $K \geq 1$. ספרו פירוקים לתת-סדרות MOOOO....O, בכל אחת בדיוק $K$ אותיות O, מודולו $10^9+7$.

המחרוזת ארוכה ולכן אינה נתונה במפורש. במקום זאת נתונים $L$ ($1 \leq L \leq 10^{18}$) ומחרוזת $T$ באורך $N$ ($1 \leq N \leq 10^6$). $S$ מחברת $L$ עותקים של $T$.

קלט

השורה הראשונה מכילה $K$, $N$ ו-$L$.

השנייה מכילה $T$ באורך $N$, כל תו M או O.

מובטח שמספר הפירוקים של $S$ אינו אפס.

פלט

הדפיסו את מספר הפירוקים של $S$ מודולו $10^9+7$.

דוגמאות

קלט 1

2 6 1
MOOMOO

פלט 1

1

הערה

הפירוק היחיד ל-MOO יוצר אחד משלושת התווים הראשונים ואחר משלושת האחרונים.

קלט 2

2 6 1
MMOOOO

פלט 2

6

הערה

יש שישה פירוקים שונים לתת-סדרות (האותיות הגדולות יוצרות MOO אחד והקטנות אחר):

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

קלט 3

1 4 2
MMOO

פלט 3

4

קלט 4

1 4 100
MMOO

פלט 4

976371285

הערה

הקפידו לקחת את התשובה מודולו $10^9+7$.

תתי משימות

  • בדיקות 5–7: $K=1$, $L = 1$
  • בדיקות 8–10: $K=2$, $N\leq 1000$, $L = 1$
  • בדיקות 11–13: $K=1$
  • בדיקות 14–19: $L = 1$
  • בדיקות 20–25: אין מגבלות נוספות.

קרדיט לבעיה: Dhruv Rohatgi

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.