QOJ.ac

QOJ

حد الوقت: 3.0 s حد الذاكرة: 512 MB مجموع النقاط: 100 قابلة للهجوم ✓

#7312. מספר כמעט Bobo

الإحصائيات

מספר שלם חיובי נקרא מספר 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\le10^{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.