QOJ.ac

QOJ

Limite de temps : 3.0 s Limite de mémoire : 512 MB Points totaux : 100 Hackable ✓

#7312. จำนวนเกือบ Bobo

Statistiques

จำนวนเต็มบวกเรียกว่า จำนวน Bobo หากรูปแทนฐานสิบของมันได้จากการนำจำนวนเต็มเดียวกันสองชุดมาต่อกัน ตัวอย่างเช่น $12341234$ และ $3232$ เป็นจำนวน Bobo แต่ $1234321$ และ $1322$ ไม่ใช่

จำนวนเต็มบวกเรียกว่า จำนวนเกือบ Bobo หากหลังจากรวมกลุ่มเลขโดดที่เหมือนกันและอยู่ติดกันทั้งหมดแล้ว จำนวนที่ได้เป็นจำนวน Bobo ตัวอย่างเช่น $1112223112233$ กลายเป็น $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.