CF850B.Arpa and a list of numbers
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 找到了一个包含 n 个数字的列表。当且仅当该列表非空且其中所有数字的最大公约数(gcd,更多信息参见“注释”部分)为 1 时,他称该列表为坏列表(bad list)。
Arpa 可以执行以下两种操作:
- 选择一个数字并将其删除,代价为 x;
- 选择一个数字并将其加 1,代价为 y。
Arpa 可以对任意多个数字执行这些操作,并且允许对同一个数字反复执行第二种操作(即多次加 1)。
请帮助 Arpa 求出使该列表变为好列表(good list)的最小总代价。
输入格式
First line contains three integers n, x and y (1 ≤ n ≤ 5·105, 1 ≤ x, y ≤ 109) — 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 ≤ 106) — the elements of the list.
第一行包含三个整数 n、x 和 y(1 ≤ n ≤ 5⋅105,1 ≤ x, y ≤ 109)—— 分别表示列表中元素的个数以及整数 x 和 y。
第二行包含 n 个整数 a1, a2, ..., an(1 ≤ ai ≤ 106)—— 表示列表中的元素。
输出格式
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.
在示例中,数字 1 必须被删除(代价为 23),数字 16 必须增加 1(代价为 17)。
一个数集的 gcd(最大公约数)是指能整除该集合中所有整数的最大整数。关于 gcd 的更多信息,请参见此处。
输入解题思路,AI测评打分。不知道怎么写?