2704. Deposits

单点时限: 2.0 sec

内存限制: 256 MB

Financial crisis forced many central banks deposit large amounts of cash to accounts of investment and savings banks in order to provide liquidity and save credit markets.

Central bank of Flatland is planning to put $n$ deposits to the market. Each deposit is characterized by its amount $a_i$.

The banks provide requests for deposits to the market. Currently there are m requests for deposits. Each request is characterized by its length $b_i$ days.

The regulations of Flatland’s market authorities require each deposit to be refinanced by equal integer amount each day. That means that a deposit with amount $a$ and a request with length $b$ match each other if and only if $a$ is divisible by $b$.

Given information about deposits and requests, find the number of deposit-request pairs that match each other.


The first line of the input file contains $n$ ― the number of deposits ($1 \le n \le 100000$). The second line contains $n$ integer numbers: $a_{1}, a_{2}, \ldots , a_{n}$ ($1 \le a_{i} \le 10^6$).

The third line of the input file contains $m$ ― the number of requests ($1 \le m \le 100000$). The forth line contains $m$ integer numbers: $b_{1}, b_{2}, \ldots , b_{m}$ ($1 \le b_{i} \le 10^6$).


Output one number ― the number of matching pairs.


3 4 5 6
1 1 2 3
The following pairs match each other: (3, 1) twice (as (a1, b1) and as (a1, b2)), (3, 3), (4, 1) twice, (4, 2), (5, 1) twice, (6, 1) twice, (6, 2), and (6, 3).

7 人解决,45 人已尝试。

11 份提交通过,共有 172 份提交。

8.7 EMB 奖励。

创建: 14 年,3 月前.

修改: 5 年,1 月前.

最后提交: 11 月,1 周前.

来源: NEERC 2008