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. ODBC总结

    引用头文件:sql.h.sqlext.h.sqltypes.h 添加库文件:odbc32.lib   odbccp32.lib 1.定义环境变量: SQLHENV henv =nullptr://环境 ...

  2. UART和RS232/RS485的关系,RS232与RS485编程

    http://wpp9977777.blog.163.com/blog/static/4625100720138495943540/ 串口通讯是电子工程师和嵌入式开发工程师面对的最基本问题,RS232 ...

  3. 常用加密算法的Java实现(一)

    常用加密算法的Java实现(一) ——单向加密算法MD5和SHA 摘自:http://www.blogjava.net/amigoxie/archive/2014/06/01/414299.html ...

  4. 大家好,我是FansUnion,雷文

    友情提示 以下是我在CSDN Code讨论组的自我介绍. 很多CSDN网友,总是重复地问我一些比较常见的问题. 我已经开始机械性地回答网友的问题了. 自我介绍 我的CSDN等媒体的ID,大多带有Fan ...

  5. ActiveX控件开发 C#

    转自:http://hi.baidu.com/charlesx_kst/item/9c2f42e2920db3f42b09a4ff 前言: 这段时间因为工作的需要,研究了一下ActiveX控件.总结如 ...

  6. 洛谷 P1097 统计数字

    P1097 统计数字 题目描述 某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*10^9).已知不相同的数不超过10000个,现在需要统计这些自然数各自出现的次数,并按照自 ...

  7. [Angular] HttpParams

    It is possible to use HttpParams to set http params. For example we have this url to make: https://a ...

  8. amazeui学习笔记--css(常用组件5)--评论列表Comment

    amazeui学习笔记--css(常用组件5)--评论列表Comment 一.总结 1.am-comment:使用am-comment来声明评论对象,这个是放在article里面的,虽然article ...

  9. POJ 3617 Best Cow Line ||POJ 3069 Saruman's Army贪心

    带来两题贪心算法的题. 1.给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下面两个操作:1.从S的头部删除一个字符,加到T的尾部.2.从S的尾部删除一个字符,加 ...

  10. 前端项目课程7 banner设计注意事项

    前端项目课程7 banner设计注意事项 一.总结 一句话总结: 1.每个部分的里面的部分可以用相同的名字么,如何修改样式呢? 可以, 用模块名 + 比如上中下(top middle bottom) ...