#P9769. [HUSTFC 2023] 简单的加法乘法计算题
[HUSTFC 2023] 简单的加法乘法计算题
Problem Description
JokerShaco has a number . Initially, , and he wants to change into . To achieve this, he can use two sets and . Set contains elements, which are all positive integers from to . Set contains elements. Each time, he can perform the following operations on any number of times:
- Choose an element from , and add to .
- Choose an element from , and multiply by .
Given , , , and the specific values of the elements in , JokerShaco wants to know the minimum number of operations needed to make become .
Input Format
The first line contains three integers , , and , with meanings as described above.
The second line contains positive integers. The -th one represents the -th element in , .
Output Format
Output one integer, representing the minimum number of operations needed to make become . Under the conditions of the problem, it is guaranteed that can always be changed into .
10 3 1
2
3
100 6 3
2 3 5
3
Hint
Translated by ChatGPT 5