当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1350:Cabric Number Problem

题目描述
If we input a number formed by 4 digits and these digits are not all of one same value, then it obeys the following law. Let us operate the number in the following way:
(1) Arrange the digits in the way from bigger to smaller, such that it forms the biggest number that could be made from these 4 digits;
(2) Arrange the digits in the way from smaller to bigger, such that it forms the smallest number that could be made from these 4 digits (If there is 0 among these 4 digits, the number obtained may be less than four digits);
(3) Find the difference of these two numbers that is a new four digital number.
Repeat the above process, we can finally always get the result 6174 or 0.
Please write the program to realize the above algorithm.
输入解释
Each case is a line of an integer.-1 denotes the end of input.
输出解释
If the integer is formed exactly by 4 digits and these digits are not all of one same value, then output from the program should show the procedure for finding this number and the number of repetition times. Otherwise output "No!!".
输入样例
5364
2221
4444
-1
输出样例
N=5364:
6543-3456=3087
8730-378=8352
8532-2358=6174
Ok!! 3 times
N=2221:
2221-1222=999
999-999=0
Ok!! 2 times
N=4444:
No!!

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Xi'an 2002

源链接: POJ-1350

最后修改于 2020-10-29T06:01:46+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536