#P6523. Chained Prime Encryption
Chained Prime Encryption
Chained Prime Encryption
In this problem, you are given a plaintext A consisting of \(n-1\) positive integers. Then, a ciphertext B of \(n\) prime numbers is constructed such that for every \(i\) with \(1 \le i < n\), the following holds:
[ B_i \times B_{i+1} = A_i ]
To improve the utilization of information, it is further required that every prime appearing in B lies in the range \([2, M]\) (note that 1 is not a prime).
Your task is to recover the sequence B given the integers \(n\), \(M\) and the sequence A.
inputFormat
The input consists of two lines. The first line contains two integers \(n\) and \(M\), where \(n\) is the length of the prime sequence \(B\) (thus the plaintext A contains \(n-1\) integers) and \(M\) is the upper bound for the primes in \(B\). The second line contains \(n-1\) space-separated integers representing the sequence A.
outputFormat
Output the sequence B as \(n\) space-separated integers on a single line.
sample
3 100
6 15
2 3 5
</p>