409028: GYM103416 H Cheap Square

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Cheap Squaretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

It is the last week before NU Open takes place. The greatest problemsetter of all time $$$krauch$$$ does not have time and money for new challenging problems. So, $$$krauch$$$ asks their boss $$$CMaster$$$ for help. But there is a thing, $$$CMaster$$$ accepts only positive whole square amount of dollars $$$\geq X$$$. $$$Krauch$$$ is out of pocket. Luckily, $$$NUBANK$$$ provides loans with low percentages, but, of course, has its own terms, the loan amount may only be the product of some bank-supported prime numbers.

More specifically, $$$NUBANK$$$ has an array of supported prime numbers, $$$p[]$$$ (not necessarily distinct) and another array $$$cost[]$$$, both of them having lengths of $$$N$$$. If you choose indices $$$j_1$$$, $$$j_2$$$ ... $$$j_m$$$, the loan amount will be $$$p_{j_1}$$$ $$$\cdot$$$ $$$p_{j_1}$$$ $$$\cdot$$$ ... $$$\cdot$$$ $$$p_{j_m}$$$ and the return cost will be $$$cost_{j_1}$$$ $$$+$$$ $$$cost_{j_1}$$$ $$$+$$$ ... $$$+$$$ $$$cost_{j_m}$$$.

Can you help $$$krauch$$$ to take a loan from $$$NUBANK$$$ to pay $$$CMaster$$$ with the minimal return cost (as $$$krauch$$$ is out of money)? Keep in mind that both the $$$NUBANK$$$ and $$$CMaster$$$ has their own terms and conditions.

Input

The first line contains two integers $$$N$$$ and $$$X$$$, $$$1 \leq N \leq 100$$$, $$$1 \leq X \leq 10^{18}$$$.

The second line contains an array of bank-supported prime numbers of length $$$N$$$, $$$p_i \leq 10^5$$$ and $$$p_i$$$ is a prime number.

The third line contains an array of $$$N$$$ numbers, cost of each bank-supported number, $$$1 \leq cost_i \leq 10^5$$$.

Output

Print the minimal possible value of the return of cost of a loan such that the loan is accepted by $$$CMaster$$$ or $$$-1$$$ if payment conditions cannot be satisfied.

ExamplesInput
7 20
2 3 23 5 3 2 5
2 1 1 6 5 2 5
Output
10
Input
3 5
2 3 2
1 2 5
Output
-1
Note

For the first sample test case, if you choose indices $$$[1, 2, 5, 6]$$$ you will have a loan of $$$36$$$ ($$$2 \cdot 3 \cdot 3 \cdot 2$$$) dollars which is both whole square and $$$\geq X$$$ thus accepted by $$$CMaster$$$, and it has a return cost of 10 dollars which is minimal among other options.

加入题单

算法标签: