Foreword
This question really is a good question.
text
analysis
First of all, we think, a number of sub changing what conditions should be met.
There can not exceed the maximum quality factor medium basis.
Then, find parent minimum number of changes to from to to break down , then save it, and finally the anti output.
why?
-
in order to the minimum number of changes in the parent, our first Ge as possible to ensure that the number of bits less.
-
Under the premise of digits as little as possible, we want the number as small as possible,
#include <bits/stdc++.h>
using namespace std;
int x=9,a[1010],len,l=1;
vector<int>v;
int main(){
char ch=getchar();
for(;!isdigit(ch);ch=getchar());
for(;isdigit(ch);ch=getchar())a[++len]=ch-'0';//读入
while(x>=2){
int y=0;
for(int i=1;i<=len;i++){
y=y*10+a[i];
y%=x;
}
if(y)x--;//如果不能整除
else{
v.push_back(x);//存入
for(int i=1;i<=len;i++){
y=y*10+a[i];
a[i]=y/x;y%=x;//除
}if(a[l]==0)l++;
}
}if(len!=l)puts("There is no such number!");
else for(int i=v.size()-1;i>=0;i--)cout<<v[i];//反着输出
return 0;
}
postscript
If you have questions, you can write it down in the comments section, so that a more complete solution of this problem.