시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 61 | 25 | 21 | 42.000% |
Archaeologists have just deciphered hieroglyphs on walls of a pyramid. The writings on one of the walls describe $N$ sacred numbers. All numbers which are divisible by at least one of these numbers are also sacred.
The writings on $M$ other walls claim that the $Q_i$-th lowest sacred number has magic properties. The archaeologists would like to know which numbers have the magic properties. Could you help them with that?
You are given $N$ positive integers $A_1, A_2, \ldots, A_N$ and $M$ positive integers $Q_1, Q_2, \ldots, Q_M$. For each $i \in \{ 1, 2, \ldots, M \}$ find the $Q_i$-th lowest positive integer which is divisible by at least one of the integers $A_1, A_2, \ldots, A_N$.
The first line of the input contains two integers $N$ a $M$. The second line contains space-separated integers $A_1$, $A_2$, $\ldots$, $A_N$. Then, $M$ lines follow. Each of them contains an integer $Q_i$.
Output $M$ lines. The $i$-th line should contain the $Q_i$-th lowest positive integer which is divisible by at least one of the integers $A_1, A_2, \ldots, A_N$.
5 5 2 5 7 10 11 1 2 3 10 20
2 4 5 14 28
2 1 70 100 5
210