1 #include <bits/stdc++.h> 2 #define _for(i,a,b) for(int i = (a);i < (b);i ++) 3 using namespace std; 4 5 int toNum(int f,int g,int h,int i,int j) 6 { 7 return f*10000+g*1000+h*100+i*10+j; 8 } 9 10 bool ok(int n,int pre) 11 { 12 int hash[10] {0}; 13 if(n>100000) 14 return false; 15 if(pre<10000) 16 hash[0] ++; 17 while(pre) 18 { 19 hash[pre % 10] ++; 20 pre /= 10; 21 } 22 while(n) 23 { 24 hash[n % 10] ++; 25 if(hash[n%10]>=2) 26 return false; 27 n /= 10; 28 } 29 _for(i,0,10) 30 if(!hash[i]) 31 return false; 32 return true; 33 } 34 35 int main() 36 { 37 int N,kase = 0;; 38 while(scanf("%d",&N) == 1 && N) 39 { 40 if(kase++ > 0) printf(" "); 41 int flag = 1; 42 _for(f,0,10) 43 { 44 _for(g,0,10) 45 { 46 if(f==g) 47 continue; 48 _for(h,0,10) 49 { 50 if(h==g||h==f) 51 continue; 52 _for(i,0,10) 53 { 54 if(i==f||i==g||i==h) 55 continue; 56 _for(j,0,10) 57 { 58 if(j==f||j==g||j==h||j==i) 59 continue; 60 int fghij = toNum(f,g,h,i,j); 61 char ts[10] {0}; 62 ts[0] = f+'0'; 63 ts[1] = g+'0'; 64 ts[2] = h+'0'; 65 ts[3] = i+'0'; 66 ts[4] = j+'0'; 67 ts[5] = '