A11078 | Arpa and a list of numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Arpa has found a list containing $n$ numbers. He calls a list bad if and only if it is not empty and gcd (see notes section for more information) of numbers in the list is $1$ .
Arpa can perform two types of operations:
- Choose a number and delete it with cost $x$ .
- Choose a number and increase it by $1$ with cost $y$ .
Arpa can apply these operations to as many numbers as he wishes, and he is allowed to apply the second operation arbitrarily many times on the same number.
Help Arpa to find the minimum possible cost to make the list good.
Arpa can perform two types of operations:
- Choose a number and delete it with cost $x$ .
- Choose a number and increase it by $1$ with cost $y$ .
Arpa can apply these operations to as many numbers as he wishes, and he is allowed to apply the second operation arbitrarily many times on the same number.
Help Arpa to find the minimum possible cost to make the list good.
输入格式
First line contains three integers $n$ , $x$ and $y$ ( $1<=n<=5·10^{5}$ , $1<=x,y<=10^{9}$ ) — the number of elements in the list and the integers $x$ and $y$ .
Second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=10^{6}$ ) — the elements of the list.
Second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=10^{6}$ ) — the elements of the list.
输出格式
Print a single integer: the minimum possible cost to make the list good.
输入输出样例
输入 #1
4 23 17 1 17 17 16
输出 #1
40
输入 #2
10 6 2 100 49 71 73 66 96 8 60 41 63
输出 #2
10
In example, number $1$ must be deleted (with cost $23$ ) and number $16$ must increased by $1$ (with cost $17$ ).
A gcd (greatest common divisor) of a set of numbers is the maximum integer that divides all integers in the set. Read more about gcd [here](https://en.wikipedia.org/wiki/Greatest_common_divisor).
A gcd (greatest common divisor) of a set of numbers is the maximum integer that divides all integers in the set. Read more about gcd [here](https://en.wikipedia.org/wiki/Greatest_common_divisor).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted