-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa_725.cpp
More file actions
61 lines (54 loc) · 1.14 KB
/
UVa_725.cpp
File metadata and controls
61 lines (54 loc) · 1.14 KB
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
/*************************************************************************
> File Name: UVa_725.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月18日 星期五 20时44分13秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 50086;
bool check(int a, int b)
{
if(b >98765) return 0;
bool v[15] = {0};
memset(v, 0, sizeof(v));
while(a)
{
v[a%10] = 1;
a /= 10;
}
while(b)
{
v[b%10] = 1;
b /= 10;
}
int sum = 0;
for(int i = 0; i < 10; i++)
{
sum += v[i];
}
return (sum == 10);
}
int main()
{
int n;
while(~scanf("%d", &n) && n)
{
int flag = 0;
for(int i = 1234; i < 50000; i++)
{
if(check(i, i*n))
{
printf("%05d / %05d = %d\n", i*n, i, n);
flag++;
}
}
if(flag == 0) printf("There are no solutions for %d.\n", n);
}
return 0;
}