题干:

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.

Examples

Input

2
4 5
3
12 13 15

Output

2

Input

4
1 2 3 4
5
10 11 12 13 14

Output

1

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 a1 = 4, b1 = 12, and for the other a2 = 5, b3 = 15.

题目大意:

给两组数a和b。 从两组中各选一个数,求最大的整数比值有多少个。

解题报告:

暴力就好了。、

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
ll a[505],b[505];
ll maxx,ans;
int n,m;
int main()
{cin>>n;for(int i = 1; i<=n; i++) scanf("%lld",a+i);cin>>m;for(int i = 1; i<=m; i++) scanf("%lld",b+i);for(int i = 1; i<=n; i++) {for(int j = 1; j<=m; j++) {if(b[j]%a[i] == 0) maxx = max(maxx,b[j]/a[i]);}}for(int i = 1; i<=n; i++) {for(int j = 1; j<=m; j++) {if(b[j]%a[i] == 0 && b[j] / a[i] == maxx) ans++;}}printf("%lld\n",ans);return 0 ;}

【CodeForces - 215A】Bicycle Chain (水题)相关推荐

  1. codeforces 1060a(思维水题)

    Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", ...

  2. Codeforces Gym 100286I iSharp 水题

    Problem I. iSharp Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...

  3. CodeForces - 1287B Hyperset(暴力水题)

    题目链接:点击查看 题目大意:给出"集合"的定义: 集合中必须有三个元素 每个元素的每个特征值必须全部相同或者全部不同,不能存在两者相同但与第三者不同 现在给出n个元素以及m个特征 ...

  4. CodeForces 931C Laboratory Work 水题,构造

    *这种题好像不用写题解... 题意: 一个人要改动别人的实验记录,实验记录记录是一个集合 实验记录本身满足:$max(X)-min(X)<=2$ 改动结果要求: 1.新的集合平均值和之前的一样 ...

  5. 【CodeForces - 1066A~E】水题,模拟(有技巧),思维,题意难懂的模拟,二进制问题(有技巧)

    A. 题目大意: x坐标上1~L有L个点都是整数,每v个长度就有一个灯亮着,但是有 [ l , r ] 这段区间上有列火车挡住了,问你能看到多少亮灯. 解题报告: 大水题啊,找几个样例就会发现需要特殊 ...

  6. CodeForces - 13A Numbers【水题】

    题目链接:https://codeforces.com/contest/13/problem/A 暴力 #include <iostream> using namespace std; i ...

  7. Educational Codeforces Round 30 A[水题/数组排序]

    A. Chores time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...

  8. CodeForces - 1042C (emmmmmm水题)

    You are given an array aa consisting of nn integers. You can perform the following operations with i ...

  9. Codeforces 864 A Fair Game 水题

    题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...

最新文章

  1. 2021-2027年中国视频监控设备行业市场需求预测与投资战略规划分析报告
  2. Oracle数据库备份与恢复的三种方法
  3. java语言描述一个行为_设计模式之责任链模式——Java语言描述
  4. guibuilder 皮肤_和平精英返场皮肤投票排名介绍-返场皮肤哪个好
  5. java vector_Java Vector elements()方法与示例
  6. 【OS学习笔记】十三 保护模式一:全局描述符表(GDT)
  7. UVA 11992 - Fast Matrix Operations(段树)
  8. Spring, Hibernate and Oracle Stored Procedures
  9. python redis 订阅发布_【Python之旅】第七篇(三):使用Redis订阅服务
  10. Acronis Disk Director 增大c盘
  11. 【JSP】 # JSP入门及简单概述
  12. 手机点餐小程序怎么弄_分享点餐小程序制作教程
  13. 【运动控制篇】(7)路径跟踪及组合动作方向
  14. fms安装教程 linux_安装FMS3 for Linux
  15. peoplesoft查询
  16. sql查询重复订单号
  17. uni-app使用,并引入thor-ui
  18. resizeEvent , paintEvent事件触发原因
  19. 引路蜂技术博客论坛开放
  20. Machine Learning上机作业ex3解答

热门文章

  1. 63. Unique Paths II and 64. Minimum Path Sum
  2. 机器学习的一些注意事项
  3. 华为云上可订阅F5_F5亮相华为云计算大会 解读云应用交付
  4. mysql日期格式化季度_mysql按年度、季度、月度、周、日统计查询的sql语句
  5. python ssh脚本_ssh爆破(python脚本)
  6. nodejs python 通信_Nodejs环境实现socket通信过程解析
  7. rs232串口驱动_RS232与RS485在性能上有啥区别和联系?老电工总结分析,一目了然...
  8. 弹出并点击弹框关闭 自定义toast_关于别名配置使用弹框交互应用的思考
  9. C#命名空间namespace中不能直接包含字段(变量)或方法(函数)之类的成员
  10. BSS段、数据段、代码段、堆与栈