B. Bash's Big Day

time limit per test

2 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.

But Zulu warns him that a group of k > 1 Pokemon with strengths {s1, s2, s3, ..., sk} tend to fight among each other if gcd(s1, s2, s3, ..., sk) = 1 (see notes for gcd definition).

Bash, being smart, does not want his Pokemon to fight among each other. However, he also wants to maximize the number of Pokemon he takes from the lab. Can you help Bash find out the maximum number of Pokemon he can take?

Note: A Pokemon cannot fight with itself.

Input

The input consists of two lines.

The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab.

The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.

Output

Print single integer — the maximum number of Pokemons Bash can take.

Examples

input

3
2 3 4

output

2

input

5
2 3 4 6 7

output

3

Note

gcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.

In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.

In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there is no larger group with gcd ≠ 1.

桶排数的因子

 //2016.01.18
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; const int N = 1e5+;
int book[N]; int main()
{
int n, a;
while(scanf("%d", &n) != EOF)
{
memset(book, , sizeof(book));
for(int i = ; i < n; i++)
{
scanf("%d", &a);
for(int j = ; j*j <= a; j++)
{
if(j*j == a)
book[j]++;
else if(a%j == )
{
book[j]++;
book[a/j]++;
}
}
}
int ans = ;
for(int i = ; i < N; i++)
if(book[i] > ans)
ans = book[i];
printf("%d\n", ans);
} return ;
}

CodeForces757B的更多相关文章

  1. CodeForces-757B Bash's Big Day

    题目链接 https://vjudge.net/problem/CodeForces-757B 题目 Description Bash has set out on a journey to beco ...

随机推荐

  1. 如何使用UDP进行跨网段广播(转)

    源:http://blog.chinaunix.net/uid-22670933-id-3716646.html 广播域首先我们来了解一下广播域的概念.广播域是网络中能接收任一台主机发出的广播帧的所有 ...

  2. ds18b20再硬件设计部分的注意事项

    1.DS18B20的供电方式: ps:寄生电源不是实际的电源器件,而是一种供电方式,即通过数据线供电. 如下面的两张图片所示,分别为外部供电模式下单只和多只DS18B20测温系统的典型电路连接图. ( ...

  3. HDU 5613 Baby Ming and Binary image

    因为第一行和最后一行都是0,我们只需枚举最左边或最右边一列的01情况,即可得到整张表 然后再检验表是否符合要求 #include<cstdio> #include<cstring&g ...

  4. iOS推送跳转AppDelegate跳转VC

    在开发项目中,会有这样变态的需求: 推送:根据服务端推送过来的数据规则,跳转到对应的控制器 feeds列表:不同类似的cell,可能跳转不同的控制器(嘘!产品经理是这样要求:我也不确定会跳转哪个界面哦 ...

  5. ACM_基础知识(二)

    1. strstr: 函数原型:extern char *strstr(char *str1, const char *str2); 功能:strstr(str1,str2) 函数用于判断字符串str ...

  6. spring调用mongodb

    1.环境 Jdk:1.6.0_10-rc2 Spring3.1.2  下载 依赖jar文件: 2.相关配置 ①.spring配置文件 <?xml version="1.0" ...

  7. set multiset 集合实现众数的统计

    众数问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 所谓众数,就是对于给定的含有N个元素的多重集合,每个元素在S中出现次数最多的成为该元素的重数, 多重集合S重 ...

  8. mysql root密码

    方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...

  9. IIS日志路径,修改存放位置,清除日志方法

    IIS存放日志文件的默认存储路径是c:\windows\system32\logfiles 我们依次打开“我的电脑”,C盘,Windows文件夹,system32文件夹,logfiles文件夹,发现里 ...

  10. jquery遍历二维数组

    function eachTowArray() {  var ar = [[1,2,3],[4,5,6],[7,8,9]];  var result="";   //结果存放变量  ...