CF757B.Bash's Big Day

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 {_s_1, _s_2, _s_3, ..., s__k} tend to fight among each other if gcd(_s_1, _s_2, _s_3, ..., s__k) = 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.

巴什踏上了成为最强宝可梦大师的旅程。为了获得他的第一只宝可梦,他来到了祖鲁教授的实验室。由于巴什是祖鲁教授最钟爱的学生,祖鲁允许他从实验室中任意挑选宝可梦。

但祖鲁警告他:当一组 k>1k > 1 只宝可梦的战力分别为 {s1,s2,s3,…,sk}\{s_1, s_2, s_3, \dots, s_k\} 时,若 gcd⁡(s1,s2,s3,…,sk)=1\gcd(s_1, s_2, s_3, \dots, s_k) = 1(gcd⁡\gcd 的定义见注释),它们便会彼此争斗。

聪明的巴什不希望自己的宝可梦互相争斗;但他同时也想尽可能多地从实验室中带走宝可梦。你能帮巴什算出他最多能带走多少只宝可梦吗?

注:一只宝可梦不会与自身发生争斗。

输入格式

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 s__i (1 ≤ s__i ≤ 105), the strength of the i-th Pokemon.

输入包含两行。

第一行包含一个整数 nn(1 ≤ n ≤ 1051 \leq n \leq 10^5),表示实验室中宝可梦的数量。

第二行包含 nn 个以空格分隔的整数,其中第 ii 个整数表示第 ii 只宝可梦的力量值 sis_i(1 ≤ si ≤ 1051 \leq s_i \leq 10^5)。

输出格式

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

输出一个整数——Bash 最多能带走的宝可梦数量。

输入输出样例

  • 输入#1

    3
    2 3 4

    输出#1

    2
  • 输入#2

    5
    2 3 4 6 7

    输出#2

    3

说明/提示

gcd (greatest common divisor) of positive integers set {_a_1, _a_2, ..., a__n} is the maximum positive integer that divides all the integers {_a_1, _a_2, ..., a__n}.

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.

正整数集合 {a1, a2, …, an}\{a_1,\,a_2,\,\dots,\,a_n\} 的 gcd(最大公约数)是指能整除所有整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n 的最大正整数。

在第一个样例中,我们可以选择强度为 {2, 4}\{2,\,4\} 的宝可梦,因为 gcd⁡(2, 4) = 2\gcd(2,\,4)\,=\,2。

在第二个样例中,我们可以选择强度为 {2, 4, 6}\{2,\,4,\,6\} 的宝可梦,且不存在满足 gcd⁡ ≠ 1\gcd\,\neq\,1 的更大规模的宝可梦组合。

输入解题思路,AI测评打分。不知道怎么写?

首页