CF215A.Bicycle Chain

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Vasya's bicycle chain drive consists of two parts: n stars are attached to the pedal axle, m 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 i-th star on the pedal axle has a__i (0 < _a_1 < _a_2 < ... < a__n) teeth, and the j-th star on the rear wheel axle has b__j (0 < _b_1 < _b_2 < ... < b__m) teeth. Any pair (i, j) (1 ≤ i ≤ n; 1 ≤ j ≤ m) is called a gear and sets the indexes of stars to which the chain is currently attached. Gear (i, j) has a gear ratio, equal to the value .

Since Vasya likes integers, he wants to find such gears (i, j), that their ratios are integers. On the other hand, Vasya likes fast driving, so among all "integer" gears (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.

瓦西娅的自行车链条传动系统由两部分组成:踏板轴上安装有 nn 个链轮,后轮轴上安装有 mm 个链轮。链条通过传递踏板的旋转来驱动后轮转动。

已知踏板轴上的第 ii 个链轮有 aia_i(满足 0<a1<a2<⋯<an0 < a_1 < a_2 < \dots < a_n)个齿,后轮轴上的第 jj 个链轮有 bjb_j(满足 0<b1<b2<⋯<bm0 < b_1 < b_2 < \dots < b_m)个齿。任意一对 (i, j)(i,\,j)(其中 1≤i≤n1 \le i \le n,1≤j≤m1 \le j \le m)称为一个“档位”,表示链条当前所连接的两个链轮的编号。档位 (i, j)(i,\,j) 的传动比等于值 。

由于瓦西娅偏爱整数,他希望找出所有满足传动比为整数的档位 (i, j)(i,\,j)。另一方面,瓦西娅也喜欢高速骑行,因此在所有这些“整数传动比”的档位 (i, j)(i,\,j) 中,他希望选出传动比最大的那个。请帮助他找出满足该最大传动比的档位的数量。

本题中,分数 表示实数除法,即不进行任何舍入操作。

输入格式

The first input line contains integer n (1 ≤ n ≤ 50) — the number of stars on the bicycle's pedal axle. The second line contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 104) in the order of strict increasing.

The third input line contains integer m (1 ≤ m ≤ 50) — the number of stars on the rear wheel axle. The fourth line contains m integers _b_1, _b_2, ..., b__m (1 ≤ b__i ≤ 104) in the order of strict increasing.

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

第一行输入包含一个整数 nn(1≤n≤501 \leq n \leq 50)——表示自行车曲柄轴上的飞轮齿数。
第二行输入包含 nn 个整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n(1≤ai≤1041 \leq a_i \leq 10^4),按严格递增顺序给出。

第三行输入包含一个整数 mm(1≤m≤501 \leq m \leq 50)——表示后轮轴上的飞轮齿数。
第四行输入包含 mm 个整数 b1, b2, …, bmb_1,\,b_2,\,\dots,\,b_m(1≤bi≤1041 \leq b_i \leq 10^4),按严格递增顺序给出。

保证至少存在一对齿轮 (i, j)(i,\,j),其传动比为整数。每行中的数字以空格分隔。

输出格式

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 _a_1 = 4, _b_1 = 12, and for the other _a_2 = 5, _b_3 = 15.

在第一个样例中,最大的“整数”传动比为 3。有两个齿轮组具有该传动比:其中一组 a1=4, b1=12a_1 = 4,\ b_1 = 12,另一组 a2=5, b3=15a_2 = 5,\ b_3 = 15。

输入解题思路,AI测评打分。不知道怎么写?

首页