time limit per test2 seconds

memory limit per test512 megabytes

inputstandard input

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

【题目链接】:http://codeforces.com/contest/757/problem/B

【题解】



枚举那个最大的组的gcd是什么(枚举那个gcd的质因子就好);

所以找出1..10W里面的所有质数S;

然后枚举以S的倍数为gcd的组的大小;

取最大值就好;



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int MAXN = 1e5+100; vector <int> v;
int n;
int a[MAXN];
int bo[MAXN]; bool is(int x)
{
int ma = sqrt(x);
rep1(i,2,ma)
if (x%i==0)
return false;
return true;
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
rep1(i,2,100000)
if (is(i))
v.pb(i);
rei(n);
rep1(i,1,n)
{
rei(a[i]);
bo[a[i]]++;
}
int len = v.size();
int ans = 1;
rep1(i,0,len-1)
{
int num = 0,x = v[i];
for (int now = x;now<=100000;now+=x)
num+=bo[now];
ans = max(ans,num);
}
printf("%d\n",ans);
return 0;
}

【codeforces 757B】 Bash's Big Day的更多相关文章

  1. 【Codeforces 757B】 Bash's big day

    [题目链接] 点击打开链接 [算法] 若gcd(s1,s2,s3....sk) > 1, 则说明 : 一定存在一个整数d满足d|s1,d|s2,d|s3....,d|sk 因为我们要使|s|尽可 ...

  2. 【codeforces 757E】Bash Plays with Functions

    [题目链接]:http://codeforces.com/problemset/problem/757/E [题意] 给你q个询问; 每个询问包含r和n; 让你输出f[r][n]; 这里f[0][n] ...

  3. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  4. 【codeforces 757A】Gotta Catch Em' All!

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  6. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  7. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  8. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  9. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

随机推荐

  1. 【2017 Multi-University Training Contest - Team 6】Inversion

    [链接]h在这里写链接 [题意] 给出一个序列,求2~n每一个数,下标不是这个数倍数的最大值是什么? [题解] 把a数组从大到小排序. 每个位置i,逆序枚举b数组,找到第一个对应下标不是i的倍数的,直 ...

  2. eclipse4.3怎么集成jadclipse追踪源代码,现在windows-preferences-java

      A.将net.sf.jadclipse_3.2.4.jar复制到D:\leaf\eclipse\plugins目录下.  B.在d:\leaf下建立ecliplsePlungin\jadclips ...

  3. CentOS 6 IPv6 关闭方法

    http://www.linuxidc.com/Linux/2012-06/63642.htm http://blog.csdn.net/ccscu/article/details/7814028

  4. IOS的UIWebView中JS点击事件,需要加入cursor:pointer;属性才可以

    IOS的UIWebView中JS点击事件,需要加入cursor:pointer;属性才可以. Android的WebView可以支持外链样式,js文件:IOS则需要改为内嵌样式和JS文件.

  5. 原生js大总结七

    061.如何获取父级节点.上一个子级节点.下一个子级节点    nextElementSibling  后一个兄弟元素  (如果没有是null)    previousElementSibling   ...

  6. 图灵机器人API,适用于微信、微博、QQ群、智能硬件等

    该API有智能聊天.查天气.查快递.查菜谱.查车票.查航班.查出行.查周边等近500个功能,能够用在微信公众平台.QQ群.手机语音助手.智能硬件等领域\ [1].[代码] [PHP]代码 跳至 [1] ...

  7. PHP从数组中删除元素的四种方法实例

    PHP从数组中删除元素的四种方法实例 一.总结 一句话总结:unset(),array_splice(),array_diff(),array_diff_key() 二.PHP从数组中删除元素的四种方 ...

  8. RMAN异机复制数据库(相同路径)

    有完整的备份,新的数据库datafile.controfile.logfile所在目录结构和原数据库一样. 创建好adump.bdump.cdump.udump等目录. 1.恢复参数文件. 设置环境变 ...

  9. ZOJ 2723 Semi-Prime ||ZOJ 2060 Fibonacci Again 水水水!

    两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F( ...

  10. System.Text.Encoding.Default

    string strTmp = "abcdefg某某某";int i= System.Text.Encoding.Default.GetBytes(strTmp).Length;/ ...