无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 215A - Bicycle Chain

2023-08-22 09:05 作者:您是打尖兒還是住店呢  | 我要投稿

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 ai (0?<?a1?<?a2?<?...?<?an) teeth, and the j-th star on the rear wheel axle has bj (0?<?b1?<?b2?<?...?<?bm) 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.


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 a1,?a2,?...,?an (1?≤?ai?≤?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 b1,?b2,?...,?bm (1?≤?bi?≤?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.


Output

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

-------------------------------

Vasya 的自行車鏈條傳動由兩部分組成:n 顆星附著在踏板軸上,m 顆星附著在后輪軸上。 鏈條通過傳遞踏板旋轉(zhuǎn)來幫助后輪旋轉(zhuǎn)。


我們知道踏板軸上的第i顆星有ai(0?<?a1?<?a2?<?...?<?an)齒,后輪軸上的第j顆星有bj(0?<?b1?<?b2?<?。 ...?<?bm) 牙齒。 任何對 (i,?j) (1?≤?i?≤?n; 1?≤?j?≤?m) 稱為齒輪,并設(shè)置鏈當(dāng)前所連接的恒星的索引。 Gear (i,?j) 的齒輪比等于值 。


由于 Vasya 喜歡整數(shù),他想找到這樣的齒輪 (i,?j),其比率為整數(shù)。 另一方面,Vasya 喜歡快速駕駛,因此在所有“整數(shù)”檔位 (i,?j) 中,他想選擇速比最大的檔位。 幫助他找到這樣的齒輪的數(shù)量。


問題中,分?jǐn)?shù)表示實數(shù)除法,即不進(jìn)行舍入。


輸入

第一個輸入行包含整數(shù) n (1?≤?n?≤?50) — 自行車踏板軸上的星星數(shù)量。 第二行包含n個整數(shù)a1,?a2,?...,?an (1?≤?ai?≤?104),按照嚴(yán)格遞增的順序。


第三輸入行包含整數(shù) m (1?≤?m?≤?50)——后輪軸上的星星數(shù)量。 第四行包含 m 個整數(shù) b1,?b2,?...,?bm (1?≤?bi?≤?104),按嚴(yán)格遞增的順序排列。


保證至少存在一個檔位(i,?j),且其傳動比為整數(shù)。 行上的數(shù)字由空格分隔。


輸出

打印所有“整數(shù)”齒輪中傳動比最大的“整數(shù)”齒輪的數(shù)量。

------------------------

一個是用來保存最大值的,一個是用來存儲每個值存在的次數(shù)的,最后返回最大值的次數(shù)即可;

下面是代碼:


CF 215A - Bicycle Chain的評論 (共 條)

分享到微博請遵守國家法律
惠来县| 塔城市| 沙湾县| 瓦房店市| 罗平县| 新安县| 中牟县| 水富县| 聂拉木县| 略阳县| 景东| 东阳市| 沐川县| 大余县| 天等县| 吴桥县| 盘锦市| 丹寨县| 黄陵县| 双辽市| 祁东县| 南丹县| 隆子县| 米脂县| 商都县| 赤城县| 蕉岭县| 山阳县| 宣威市| 岫岩| 霞浦县| 台东县| 新昌县| 资源县| 稻城县| 三原县| 兴义市| 竹北市| 民县| 鸡西市| 中超|