QOJ.ac

QOJ

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

#7312. Số gần Bobo

Statistics

Một số nguyên dương được gọi là số bobo nếu biểu diễn thập phân của nó có thể thu được bằng cách ghép hai bản sao của cùng một số nguyên. Ví dụ, $12341234$ và $3232$ là các số bobo, còn $1234321$ và $1322$ thì không.

Một số nguyên dương được gọi là số gần bobo nếu sau khi gộp mỗi nhóm chữ số bằng nhau liên tiếp thành một chữ số, số thu được là một số bobo. Ví dụ, $\underbrace{111}\underbrace{222}\underbrace{3}\underbrace{11}\underbrace{22}\underbrace{33}$ trở thành $123123$ sau khi gộp tất cả các chữ số bằng nhau liên tiếp, và do đó là một số gần bobo.

Bobo có một số rất lớn $n$, và cậu muốn biết số gần bobo lớn nhất nhỏ hơn $n$.

Dữ liệu vào

Đầu vào chứa không hoặc nhiều bộ dữ liệu thử và kết thúc khi hết tệp. Với mỗi bộ dữ liệu thử:

Dòng đầu tiên chứa một số nguyên $n$ không có chữ số không ở đầu ($1\le n\le 10^{5\,000\,000}$).

Tổng độ dài biểu diễn thập phân của tất cả các số $n$ trong đầu vào được đảm bảo không vượt quá $5\,000\,000$.

Dữ liệu ra

Với mỗi bộ dữ liệu thử, in ra một số nguyên không có chữ số không ở đầu, biểu thị số gần bobo lớn nhất nhỏ hơn hẳn $n$. Nếu không tồn tại số nguyên như vậy, hãy in -1.

Ví dụ

Dữ liệu vào 1

12345
67890
11111
1000
26782641

Dữ liệu ra 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.