시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 180 | 36 | 26 | 20.472% |
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:
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!!
ICPC > Regionals > Asia East Continent > China > Xi'an > Xi'an Regional Contest 2002 C번