-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path686_24en23B.cpp
66 lines (52 loc) · 871 Bytes
/
686_24en23B.cpp
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
// Usuario de Acepta el reto: jjjjjjjp022
#include <iostream>
#include <vector>
using lli = long long int;
using namespace std;
lli contar(lli num){
lli ret = 0;
while(num != 0) {
num/=10;
ret++;
}
return ret;
}
bool comprobar(lli &a, lli &b) {
vector<bool> v(10, false);
while(a != 0) {
if(v[a%10] == true && a%10 > 0)
return false;
v[a%10] = true;
a /= 10;
}
while(b != 0) {
if(v[b%10] == true && b%10 > 0)
return false;
v[b%10] = true;
b /= 10;
}
for(int i = 1; i < 10; i++) {
if(!v[i])
return false;
}
return true;
}
int main() {
lli a, b;
cin >> a >> b;
while(a > 0) {
//Resolver
lli cont = 0, it = 2;
lli x = a*it;
lli y = b*it;
while(contar(x) + contar(y) <= 9) {
if(comprobar(x, y))
cont++;
it++;
x = a*it;
y = b*it;
}
cout << cont << '\n';
cin >> a >> b;
}
}