# 5位黑洞数

5位黑洞数

``[82962, 75933, 63954, 61974]``

``````#include<stdio.h>
int main()
{
printf("[74943, 62964, 71973, 83952]\n[63954, 61974, 82962, 75933]\n[53955, 59994]");
}``````

``````#include<bits/stdc++.h>
using  namespace std;
#define maxn 100005
int use[maxn],vis[maxn];
bool ju(int x){
if(x%10!=x/10%10)return 0;
if(x%10!=x/100%10)return 0;
if(x%10!=x/1000%10)return 0;
if(x%10!=x/10000)return 0;
return 1;
}
void doit(int x){
int a[6],b[6],c[6];
queue<int>q;
while(1){
a[1]=x/10000;
a[2]=x/1000%10;
a[3]=x/100%10;
a[4]=x/10%10;
a[5]=x%10;
sort(a+1,a+1+5);
int i,j;
for(i=1,j=5;i<=5;++i,--j)b[i]=a[j];
int minn=a[1]*10000+a[2]*1000+a[3]*100+a[4]*10+a[5];
int maxx=b[1]*10000+b[2]*1000+b[3]*100+b[4]*10+b[5];
x=maxx-minn;
if(use[x])break;
if(vis[x]){
while(q.front()!=x)q.pop();
cout<<"[";
i=1;
while(!q.empty()){
if(i!=1){cout<<", ";}
int x=q.front();
use[x]=1;
cout<<x;
q.pop();
i++;
}
cout<<"]\12";
}
else {
vis[x]=1;
q.push(x);
}
}
}
int main(){
/*memset(use,0,sizeof(use));
for(int i=10000;i<100000;++i){
if(ju(i))continue;
memset(vis,0,sizeof(vis));
doit(i);
}*/
printf("[74943, 62964, 71973, 83952]\n[63954, 61974, 82962, 75933]\n[53955, 59994]\n");
return 0;
}
``````