1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
#define CLR(x,y) memset((x),(y),sizeof((x)))
#define FOR(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define FORD(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
#define FOR2(x,y,z) for((x)=(y);(x)<(z);(x)++)
#define FORD2(x,y,z) for((x)=(y);(x)>=(z);(x)--)
int check( int a, int b){
if (b > 98765) return 0;
int vis[10],k,cnt = 0;
CLR(vis,0);
while (a){
k = a % 10;
if (vis[k]) return 0;
else ++vis[k];
a /= 10;
}
while (b){
k = b % 10;
if (vis[k]) return 0;
else ++vis[k];
b /= 10;
}
FOR(i,1,10){
if (vis[i]) ++cnt;
}
return cnt == 9;
}
int main(){
int n,cntcase = 0;
while (~ scanf ( "%d" ,&n) && n){
if (cntcase++) puts ( "" );
int cnt = 0;
for ( int i = 01234;i <= 98765;++i){
if (check(i,i*n)){
++cnt;
printf ( "%05d / %05d = %d\n" ,i*n,i,n);
}
}
if (!cnt) printf ( "There are no solutions for %d.\n" ,n);
}
return 0;
}
|