QOJ.ac

QOJ

Süre Sınırı: 10 s Bellek Sınırı: 256 MB Toplam puan: 100

#23801. טבעת

İstatistikler

יש ברשותך $N$ טבעות. על כל טבעת חרוטה מחרוזת המורכבת מ-$10$ אותיות גדולות באנגלית. האותיות חרוטות על הטבעת כך שהתחלת המחרוזת וסופה מחוברים זה לזה. אין צורך לחשוש מקריאת המחרוזת החרוטה על הטבעת בסדר הפוך.

בהינתן המחרוזת לחיפוש, כתבו תוכנית המוצאת כמה טבעות מכילות את המחרוזת הזו.

קלט

הקלט מורכב מ-$2+N$ שורות.

בשורה $1$ כתובה המחרוזת לחיפוש, המורכבת מלפחות אות $1$ ולכל היותר $10$ אותיות גדולות באנגלית.

בשורה $2$ כתוב מספר הטבעות $N$ ($1 \le N \le 100$).

בשורה $2+i$ ($1 \le i \le N$) כתובה מחרוזת בת $10$ תווים החרוטה על הטבעת ה-$i$.

פלט

הדפיסו בשורה $1$ מספר שלם המייצג את מספר הטבעות המכילות את המחרוזת לחיפוש.

דוגמאות

קלט 1

ABCD
3
ABCDXXXXXX
YYYYABCDXX
DCBAZZZZZZ

פלט 1

2

קלט 2

XYZ
1
ZAAAAAAAXY

פלט 2

1

קלט 3

PQR
3
PQRAAAAPQR
BBPQRBBBBB
CCCCCCCCCC

פלט 3

2

הערה

בטבעת שבדוגמת קלט $2$ מופיעה המחרוזת XYZ פעם $1$. זאת משום שהתחלת המחרוזת וסופה על הטבעת מחוברים.

בדוגמת קלט $3$, הטבעת ה-$1$ מכילה $2$ מופעים של המחרוזת PQR, הטבעת ה-$2$ מכילה מופע $1$ של המחרוזת PQR, והטבעת ה-$3$ אינה מכילה את המחרוזת PQR. לכן מספר הטבעות המכילות את המחרוזת PQR הוא $2$.

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.