QOJ.ac

QOJ

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

#21074. الشفرة السرية

Statistics

لدى Farmer John رسالة سرية يريد إخفاءها عن أبقاره؛ هي سلسلة طولها اثنان على الأقل وتحتوي فقط على الأحرف A..Z.

لتشفير الرسالة يطبق FJ سلسلة من «العمليات». تقصر العملية السلسلة $S$ أولًا بحذف أول حرف أو آخر حرف منها، ثم تلحق السلسلة الأصلية $S$ بالبداية أو النهاية. مثلًا، قد تعطي عملية واحدة على ABCD أربع سلاسل:

BCDABCD ABCABCD ABCDABC ABCDBCD

عند إعطاء السلسلة المشفرة النهائية، احسب عدد الطرق التي يمكن أن يكون FJ قد أنتجها بها بتطبيق عملية واحدة أو أكثر تباعًا على سلسلة أصلية ما. تعد العمليات مختلفة حتى إن أعطت التشفير نفسه. مثلًا، توجد أربع طرق مختلفة للحصول على AAA من AA، تقابل العمليات الأربع أعلاه.

الإدخال

  • السطر $1$: سلسلة طولها لا يتجاوز 100.

الإخراج

  • السطر $1$: عدد الطرق المختلفة لإنتاج هذه السلسلة بتطبيق عملية واحدة أو أكثر تباعًا على سلسلة أصلية طولها اثنان على الأقل. إذا لم توجد أي طريقة، اطبع صفرًا.

أمثلة

الإدخال 1

ABABA

الإخراج 1

6

ملاحظة

فيما يلي الطرق المختلفة لإنتاج ABABA:

  1. البدء بالسلسلة: ABA -> AB+ABA
  2. البدء بالسلسلة: ABA -> ABA+BA
  3. البدء بالسلسلة: AB -> AB+A -> AB+ABA
  4. البدء بالسلسلة: AB -> AB+A -> ABA+BA
  5. البدء بالسلسلة: BA -> A+BA -> AB+ABA
  6. البدء بالسلسلة: BA -> A+BA -> ABA+BA

مؤلفا المسألة: Brian Dean وLewin Gan

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.