Ուղարկել | Բոլոր լուծումները | Լավագույն լուծումները | Վերադառնալ ցուցակին |
ACM_0167 - DEPOSITS |
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 ai.
For example, if they already have prizes for 2, 3 and 9 dollars, and they want to buy 2 prizes, they should buy prizes for 1 and 7 dollars. Then the winner of the show would be able to collect prizes for any score from 1 to 22.
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.
Input
The first line of the input file contains n — the number of deposits. The second line contains n integer numbers: a1, a2, …, an. (1 ≤ n ≤ 100000, 1 ≤ ai ≤ 106)
The third line of the input file contains m — the number of requests. The forth line contains m integer numbers: b1, b2, …, bm. (1 ≤ m ≤ 100000, 1 ≤ bi ≤ 106)
Output
Output one number — the number of matching pairs.
For sample test 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).
Examples
№ |
stdin |
stdout |
1 |
|
|
Ավելացրեց. | Հրանտ Հովհաննիսյան |
Ամսաթիվ. | 2014-04-09 |
Ժամանակի սահմանափակումը. | 1s |
Ծրագրի տեքստի սահմանափակումը. | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Լեզուներ. | Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE |
Աղբյուրը. | Northern QF 2008.D |