CF850B.Arpa and a list of numbers

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Arpa has found a list containing nn 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 11 .

Arpa can perform two types of operations:

  • Choose a number and delete it with cost xx .
  • Choose a number and increase it by 11 with cost yy .

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 nn , xx and yy ( 1<=n<=51051<=n<=5·10^{5} , 1<=x,y<=1091<=x,y<=10^{9} ) — the number of elements in the list and the integers xx and yy .

Second line contains nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1061<=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 11 must be deleted (with cost 2323 ) and number 1616 must increased by 11 (with cost 1717 ).

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.

首页