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. iOS中4种判断网络请求的方式(系统状态栏、AFNetworking、Reachability、自定义)

    iOS 实时判断网络状态 方法一:利用系统状态栏判断网络状态 // 状态栏是由当前app控制的,首先获取当前app UIApplication *app = [UIApplication shared ...

  2. struts2-----新建项目

    1. 建立界面原型 2. 建立Struts.xml 确定namespace, package, action, 空方法, result, 界面原型修改, 匹配现有设置, 测试, 做好规划 3. 建立数 ...

  3. hibernate--多对多单向关联 (重点!!!)

    老师和学生的关系, 一个老师对多个学生, 一个学生也对应多个老师. 数据库会需要3个表, 一个老师表, 一个学生表, 一个老师对应学生表. 单向: 老师知道自己有多少学生, 但是学生不知道自己有多少个 ...

  4. PHP获取当期前运行文件的路径,名字,服务器路径

    <?phpecho "显示脚本文件的相对路径和文件名:\"".$_SERVER["PHP_SELF"]."\"<br& ...

  5. Xcode崩溃问题调试 signal SIGABRT&EXC_BAD_ACCESS

    在进行app开发过程中会遇到很多的问题,各种崩溃令人相当头疼.当然,解决bug的能力也体现了一个程序员的水平,现在来说一说开发中经常遇到的崩溃问题吧. 常见崩溃问题: 一是signal SIGABRT ...

  6. source command not found in sh shell解决办法

    在Ubuntu系统中执行脚本的时候突然出现错误"source command not found in sh shell" 这个其实在Ubuntu 当中 执行脚本默认的使用的是da ...

  7. [Unity]SQLite-C#调用

    SQLite数据库-Unity操作 项目开发的时候,经常会遇到的一种需求,数据存储 离线缓存的数据类型很多,大致分成两类 字符串文本数据 多媒体数据 字符串数据的类型只有字符串,但是结构有很多: xm ...

  8. Grunt 入门

    转自:http://user.qzone.qq.com/174629171/blog/1404433906 Grunt被定义为:the javascript task runner. 什么算是Java ...

  9. 51nod1119(除法取模)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1119 题意:中文题诶- 思路:这题数据比较大直接暴力肯定是不 ...

  10. doxygen 生成源码文档

    使用doxygen 生成源代码的文档是相当方便的,本文就简单整理下doxygen的使用说明 1. 安装 关于安装的问题不做特殊的说明,这里直接使用命令安装, 源码安装不做介绍 ubuntu: sudo ...