A10679 | Bash's Big Day
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The input consists of two lines.
The first line contains an integer $n$ ( $1<=n<=10^{5}$ ), 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}<=10^{5}$ ), the strength of the $i$ -th Pokemon.
The first line contains an integer $n$ ( $1<=n<=10^{5}$ ), 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}<=10^{5}$ ), the strength of the $i$ -th Pokemon.
输出格式
Print single integer — the maximum number of Pokemons Bash can take.
输入输出样例
输入 #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$ .
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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted