Translation Notice
This article was machine-translated using DeepSeek-R1.
- Original Version: Authored in Chinese by myself
- Accuracy Advisory: Potential discrepancies may exist between translations
- Precedence: The Chinese text shall prevail in case of ambiguity
- Feedback: Technical suggestions regarding translation quality are welcomed
Original Problem Links: Luogu; AtCoder
Approach
Generate subsequent digits as (last digit -1)/last digit/(last digit +1) based on the previous digit, enqueue them, then output the K-th dequeued integer.
Notes
- Using
int
instead oflong long
will cause WA! - When last digit is 0, next digit cannot be -1 (special case)
- When last digit is 9, next digit cannot be 10 (special case)
Code
|
|