-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPE32.cpp
48 lines (48 loc) · 1.24 KB
/
PE32.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
#include <cstdio>
#include <set>
int main() {
int n;
scanf("%d", &n);
std::set<long long> res;
for(int i = 1; i <= n; ++i) {
for(int j = i; j <= n; ++j) {
bool use[10] = {};
use[0] = true;
long long ci = i, cj = j, ck = 1LL * i * j;
while(ci) {
int v = ci % 10;
if(use[v])
goto err;
use[v] = true;
ci /= 10;
}
while(cj) {
int v = cj % 10;
if(use[v])
goto err;
use[v] = true;
cj /= 10;
}
while(ck) {
int v = ck % 10;
if(use[v])
goto err;
use[v] = true;
ck /= 10;
}
for(int i = 1; i < 10; ++i)
if(!use[i])
goto err;
printf("%d*%d=%lld\n", i, j, 1LL * i * j);
res.insert(i * j);
err : {}
}
printf("%d\n", i);
}
long long sum = 0;
for(std::set<long long>::iterator it = res.begin();
it != res.end(); ++it)
sum += *it;
printf("%lld\n", sum);
return 0;
}