-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
64 lines (59 loc) · 957 Bytes
/
A.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
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define INF64 0x3f3f3f3f3f3f3f3f
void slove()
{
int n, m, q, tmp;
cin >> n >> m >> q;
unordered_set<int> pages;
vector<int> readers(q, 0);
for (int i = 0; i < m; ++i)
{
cin >> tmp;
pages.insert(tmp);
}
for (int i = 0; i < q; ++i)
{
cin >> readers[i];
}
vector<int> count(n + 1, 0);
for (int i = 1; i <= n; ++i)
{
int cnt = n / i;
for (int j = i; j <= n; j += i)
{
if (pages.count(j))
cnt--;
}
count[i] = cnt;
}
ll res = 0;
for (auto reader : readers)
{
res += count[reader];
}
cout << res << endl;
}
int main()
{
int t = 0;
cin >> t;
for (int i = 1; i <= t; ++i)
{
cout << "Case #" << i << ": ";
slove();
}
return 0;
}