Description
If a number is the sum of an integer’s several shifting forms, it is called the Shift Number.
For example, by shifting 123 four times and adding the four numbers together, we get 136653, which is a Shift Number.
However, a shift number may be the sum of more than one integer’s shifting forms. Such as, 45177 is a Shift Number, which could be generated from both 407 and 4107.
123+1230+12300+123000=136653
407+4070+40700=45177
4107+41070=45177
Given a Shift Number x , would you please help us find the least integer which could generate x by shifting.
Input Description
A shift number x.
Input ends with x=0.
Input ends with x=0.
Output Description
the least integer which could generate x by shifting.
Sample Input
136653 45177 0
Sample Output
123 407
补选赛时做的题。补上代码了。说下思路
由题可得等式a*10^0+a*10^1+a*10^2+.....=n.
所以只需整除即可得到a。越小越好。此题long long 可做