标签:注意 eve math code count pre rev ever line
注意不满\(4\)位的话要补成\(4\)位。
string s;
set<int> S;
int main()
{
cin>>s;
while(s.size()<4) s=‘0‘+s;
while(true)
{
sort(s.begin(),s.end(),greater<char>());
string sa=s;
reverse(s.begin(),s.end());
string sb=s;
int a=stoi(sa),b=stoi(sb);
int res=a-b;
if(S.count(res)) break;
else
{
printf("%04d - %04d = %04d\n",a,b,res);
S.insert(res);
s=to_string(res);
while(s.size()<4) s=‘0‘+s;
}
}
//system("pause");
return 0;
}
1069 The Black Hole of Numbers (20 分)
标签:注意 eve math code count pre rev ever line
原文地址:https://www.cnblogs.com/fxh0707/p/14397724.html