-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9575.cpp
79 lines (71 loc) · 1.34 KB
/
9575.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
67
68
69
70
71
72
73
74
75
76
77
78
79
// 9575. 행운의 수
// 2021.11.04
// 브루트 포스
#include<iostream>
#include<set>
#include<vector>
using namespace std;
auto check(int sum) -> bool
{
while (sum > 0)
{
int x = sum % 10;
if (x != 5 && x != 8)
{
return false;
}
sum /= 10;
}
return true;
}
set<int> sets;
int main()
{
int t;
cin >> t;
vector<int> a;
vector<int> b;
vector<int> c;
while (t-- > 0)
{
sets.clear();
a.clear();
b.clear();
c.clear();
int n, m, o;
cin >> n;
a.resize(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
cin >> m;
b.resize(m);
for (int i = 0; i < m; i++)
{
cin >> b[i];
}
cin >> o;
c.resize(o);
for (int i = 0; i < o; i++)
{
cin >> c[i];
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
for (int k = 0; k < o; k++)
{
int sum = a[i] + b[j] + c[k];
if (check(sum))
{
sets.insert(sum);
}
}
}
}
cout << sets.size() << endl;
}
return 0;
}