#P6756. [BalticOI 2013] Brunhilda's Birthday
[BalticOI 2013] Brunhilda's Birthday
Problem Description
There is an integer and a prime list of length .
You may perform any number of operations. In each operation, you choose a prime , which changes to .
Your goal is to find the minimum number of operations needed to make become . If it is impossible to make it , output oo.
To make it harder, you need to answer queries of .
Input Format
The first line contains two integers .
The next line contains integers .
The next lines each contain one integer , representing the value of given in each query.
Output Format
For each query, output the minimum number of operations needed to make become . If it is impossible, output oo.
2 2
2 3
5
6
3
oo
Hint
Constraints and Limits
- For the testdata worth points, it is guaranteed that .
- For another points of testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , and is prime, and .
Notes
This problem is translated from Baltic Olympiad in Informatics 2013 Day 2 T1 Brunhilda’s Birthday.
Because the translator could not find a suitable setting, this problem has a full score of points.
Translated by ChatGPT 5