国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
宁国市| 遂昌县| 罗山县| 南昌县| 芒康县| 桃江县| 晋宁县| 进贤县| 长白| 涟源市| 上栗县| 莲花县| 巨鹿县| 山西省| 临西县| 清远市| 梁河县| 聂拉木县| 达州市| 紫金县| 宁武县| 三门峡市| 柯坪县| 开原市| 青岛市| 夏津县| 罗定市| 怀仁县| 阿克苏市| 略阳县| 屏南县| 柳州市| 遵义市| 平泉县| 吉首市| 黔江区| 且末县| 忻州市| 通辽市| 莱芜市| 麻江县|