#P1532. 卡布列克圆舞曲
卡布列克圆舞曲
Description
Kaprekar was a mathematician. He discovered that for any four-digit number not composed of completely identical digits: if you reorder its digits to form the largest number and the smallest number, then subtract the smaller from the larger; if the difference has fewer than four digits, pad with leading zeros; and repeat this process, it will eventually become a fixed number , which is the Kaprekar constant. For example:
.
.
.
.
If a K-digit number is processed in the same way, it does not become a single number but forms a cycle among several numbers, called the Kaprekar Waltz. For example, for the five-digit number :
.
.
.
.
.
.
We call 82962, 75933, 63954, 61974 the repeating cycle, i.e., the Kaprekar Waltz.
Input Format
Multiple lines. Each line contains a starting integer for which to find the "Kaprekar Waltz" ().
Output Format
For each input integer, output the corresponding cycle terms on one line, separated by spaces.
4321
54321
6174
82962 75933 63954 61974
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号