QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#7312. عدد شبه Bobo

Statistics

يُسمى العدد الصحيح الموجب عدد Bobo إذا أمكن الحصول على تمثيله العشري بوصل نسختين من العدد الصحيح نفسه. مثلًا، $12341234$ و$3232$ عددان من أعداد Bobo، بينما $1234321$ و$1322$ ليسا كذلك.

يُسمى العدد الصحيح الموجب عددًا شبه Bobo إذا كان العدد الناتج بعد دمج جميع الأرقام المتساوية المتتالية عدد Bobo. مثلًا، يصبح $\underbrace{111}\underbrace{222}\underbrace{3}\underbrace{11}\underbrace{22}\underbrace{33}$ هو $123123$ بعد دمج جميع الأرقام المتساوية المتتالية، ولذلك فهو عدد شبه Bobo.

لدى Bobo عدد كبير جدًا $n$، ويريد معرفة أكبر عدد شبه Bobo أصغر من $n$.

الإدخال

يحتوي الإدخال على صفر أو أكثر من حالات الاختبار، وينتهي بنهاية الملف. لكل حالة اختبار:

يحتوي السطر الأول على عدد صحيح $n$ من دون أصفار بادئة ($1 \le n \le 10^{5\,000\,000}$).

من المضمون أن الطول الإجمالي للتمثيلات العشرية لجميع الأعداد $n$ في الإدخال لا يتجاوز $5\,000\,000$.

الإخراج

لكل حالة اختبار، اطبع عددًا صحيحًا من دون أصفار بادئة يمثل أكبر عدد شبه Bobo أصغر تمامًا من $n$. إذا لم يوجد عدد صحيح كهذا، فاطبع $-1$ بدلًا منه.

أمثلة

الإدخال 1

12345
67890
11111
1000
26782641

الإخراج 1

12212
67767
11010
-1
26777267

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.