本文共 2509 字,大约阅读时间需要 8 分钟。
Problem D. DepositsInput file: deposits.inOutput file: deposits.outTime limit: 3 secondsMemory limit: 256 megabytesFinancial crisis forced many central banks deposit large amounts of cash to accounts of investment andsavings 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 byits amount ai.The banks provide requests for deposits to the market. Currently there are m requests for deposits. Eachrequest is characterized by its length bi days.The regulations of Flatland’s market authorities require each deposit to be refinanced by equal integeramount each day. That means that a deposit with amount a and a request with length b match eachother if and only if a is divisible by b.Given information about deposits and requests, find the number of deposit-request pairs that match eachother.InputThe first line of the input file contains n — the number of deposits (1 ≤ n ≤ 100 000). The second linecontains 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 linecontains m integer numbers: b1, b2, . . . , bm (1 ≤ bi ≤ 106).OutputOutput one number — the number of matching pairs.Exampledeposits.in deposits.out43 4 5 641 1 2 312The 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).
#include#include #include #include #include #include #include
//// main.cpp// 160929//// Created by 刘哲 on 17/4/6.// Copyright © 2016年 my_code. All rights reserved.////#include#include #include #include #include #include #include #include
转载地址:http://avali.baihongyu.com/