1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <map> 5 #include <set> 6 #include <algorithm> 7 #include <fstream> 8 #include <cstdio> 9 #include <cmath> 10 #include <stack> 11 #include <queue> 12 using namespace std; 13 const double Pi=3.14159265358979323846; 14 typedef long long ll; 15 const int MAXN=5000+5; 16 const int dx[5]={0,0,0,1,-1}; 17 const int dy[5]={1,-1,0,0,0}; 18 const int INF = 0x3f3f3f3f; 19 const int NINF = 0xc0c0c0c0; 20 const ll mod=1e9+7; 21 int a[10]; 22 int main() 23 { 24 int n;int cnt=0; 25 while(cin>>n&&n!=0) 26 { 27 if(cnt++ != 0) cout<<endl; 28 int s=1; 29 for(int i=12345;i<=98765;i++) 30 { 31 memset(a,0,sizeof(a)); 32 if(i%n==0) 33 { 34 //6cout <<i<<endl; 35 int m=i/n; 36 if(m>1233) 37 { 38 int t=i;if(m<10000) a[0]=1; 39 while(t) 40 { 41 a[t%10]=1;t/=10; 42 } 43 while(m) 44 { 45 a[m%10]=1;m/=10; 46 } 47 } 48 int flag=1; 49 for(int j=0;j<=9;j++) 50 { 51 if(a[j]==0) 52 { 53 flag=0; 54 break; 55 } 56 } 57 /*for(int j=0;j<=9;j++) 58 { 59 cout <<a[j]<<" "; 60 } 61 cout <<endl;*/ 62 if(flag) 63 { 64 if(i/n<10000) printf("%d / 0%d = %d\n",i,i/n,n); 65 else printf("%d / %d = %d\n",i,i/n,n); 66 s=0; 67 } 68 } 69 70 } 71 if(s) printf("There are no solutions for %d.\n",n); 72 } 73 return 0; 74 }
要注意输出,最后一组数据不能再输出空行