File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #define ms (x,v ) memset((x),v,sizeof (x))
3
+ #define INF 0x3f3f3f3f
4
+ using namespace std ;
5
+
6
+ const int MAXN = 100 +10 ;
7
+ typedef long long LL;
8
+
9
+
10
+ void solve (){
11
+ int N,M,Q;
12
+ cin >> N >> M >> Q;
13
+ vector<bool > pg (N+1 ,true );
14
+ for (int i=0 ; i<M ; ++i){
15
+ int x;cin >> x;
16
+ pg[x] = false ;
17
+ }
18
+ vector<int > cnt (N+1 ,0 );
19
+ for (int i=0 ; i<Q; ++i)
20
+ {
21
+ int x;
22
+ cin >> x;
23
+ cnt[x] ++;
24
+ }
25
+ LL ans =0 ;
26
+ for (int i=1 ; i<=N ; ++i){
27
+ if (cnt[i]){
28
+ LL v = 0 ;
29
+ for (int j=i ; j<=N; j += i){
30
+ v += pg[j];
31
+ }
32
+ ans += v * cnt[i];
33
+ }
34
+ }
35
+ cout << ans << ' \n ' ;
36
+ }
37
+
38
+
39
+
40
+
41
+ int main (){
42
+ ios :: sync_with_stdio (0 );
43
+ cin.tie (0 );
44
+ // cout.tie(0);
45
+ std::cout.precision (10 );
46
+ std::cout.setf ( std::ios::fixed, std:: ios::floatfield );
47
+
48
+ int T;
49
+ cin >> T;
50
+ for (int tt =1 ; tt <=T ; ++tt)
51
+ {
52
+ cout << " Case #" << tt << " : " ;
53
+ solve ();
54
+ }
55
+
56
+
57
+ return 0 ;
58
+ }
You can’t perform that action at this time.
0 commit comments