Codeforces Round 132 (Div. 2)
A
Bicycle Chain
Codeforces
900
原题
←B →
翻译中…

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

翻译中…

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 image denotes division in real numbers, that is, no rounding is performed.

翻译中…

Input

翻译中…

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*} ≤ 10^{4})$ 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*} ≤ 10^{4})$ 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.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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

翻译中…

样例

Input #1
2
4 5
3
12 13 15
Output #1
2
InputCopy OutputCopy
Input #2
4
1 2 3 4
5
10 11 12 13 14
Output #2
1
InputCopy OutputCopy
题目信息
题号
215A
时间限制
2 s
内存限制
256 MB
标签
暴力
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。