Logo
(追記) (追記ここまで)

3574번 - Deposits 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB1612866.667%

문제

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.

The banks provide requests for deposits to the market. Currently there are m requests for deposits. Each request is characterized by its length bi 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 ≤ n ≤ 100 000). The second line contains n integer numbers: a1, a2, . . . , an (1 ≤ ai ≤ 106).

The third line of the input file contains m — the number of requests (1 ≤ m ≤ 100 000). The forth line contains m integer numbers: b1, b2, . . . , bm (1 ≤ bi ≤ 106).

출력

Output one number — the number of matching pairs.

제한

예제 입력 1

4
3 4 5 6
4
1 1 2 3

예제 출력 1

12

힌트

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).

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > NEERC Northern Subregional 2008 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /