CF215A.Bicycle Chain

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya's bicycle chain drive consists of two parts: nn stars are attached to the pedal axle, mm stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation.

We know that the ii -th star on the pedal axle has aia_{i} (0<a_{1}<a_{2}<...<a_{n}) teeth, and the jj -th star on the rear wheel axle has bjb_{j} (0<b_{1}<b_{2}<...<b_{m}) teeth. Any pair (i,j)(i,j) (1<=i<=n(1<=i<=n ; 1<=j<=m)1<=j<=m) is called a gear and sets the indexes of stars to which the chain is currently attached. Gear (i,j)(i,j) has a gear ratio, equal to the value .

Since Vasya likes integers, he wants to find such gears (i,j)(i,j) , that their ratios are integers. On the other hand, Vasya likes fast driving, so among all "integer" gears (i,j)(i,j) he wants to choose a gear with the maximum ratio. Help him to find the number of such gears.

In the problem, fraction denotes division in real numbers, that is, no rounding is performed.

输入格式

The first input line contains integer nn (1<=n<=50)(1<=n<=50) — the number of stars on the bicycle's pedal axle. The second line contains nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} (1<=ai<=104)(1<=a_{i}<=10^{4}) in the order of strict increasing.

The third input line contains integer mm (1<=m<=50)(1<=m<=50) — the number of stars on the rear wheel axle. The fourth line contains mm integers b1,b2,...,bmb_{1},b_{2},...,b_{m} (1<=bi<=104)(1<=b_{i}<=10^{4}) in the order of strict increasing.

It is guaranteed that there exists at least one gear ( i,ji,j ), that its gear ratio is an integer. The numbers on the lines are separated by spaces.

输出格式

Print the number of "integer" gears with the maximum ratio among all "integer" gears.

输入输出样例

  • 输入#1

    2
    4 5
    3
    12 13 15
    

    输出#1

    2
    
  • 输入#2

    4
    1 2 3 4
    5
    10 11 12 13 14
    

    输出#2

    1
    

说明/提示

In the first sample the maximum "integer" gear ratio equals 3. There are two gears that have such gear ratio. For one of them a1=4,b1=12a_{1}=4,b_{1}=12 , and for the other a2=5,b3=15a_{2}=5,b_{3}=15 .

首页