Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <bitset>
- #include <iostream>
- #include <stack>
- #include <queue>
- #include <set>
- #include <map>
- #include <string>
- #include <algorithm>
- using namespace std;
- const int N = 100100;
- int a[N];
- int b[10*N];
- int main() {
- freopen("deposits.in", "r", stdin);
- freopen("deposits.out", "w", stdout);
- int n, m;
- scanf("%d", &n);
- for(int i = 0; i < n; ++i) scanf("%d", &(a[i]));
- scanf("%d", &m);
- int t;
- for(int i = 0; i < m; ++i) {
- scanf("%d", &t);
- b[t]++;
- }
- long long int ans = 0;
- for(int i = 0; i < n; ++i) {
- for(int d = 1; d * d <= a[i]; ++d) {
- if (a[i] % d == 0) {
- ans += b[d];
- t = a[i] / d;
- if (t != d) ans += b[a[i] / d];
- }
- }
- }
- printf("%lld", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement