#P15913. [TOPC 2024] In Search of the Lost Array
[TOPC 2024] In Search of the Lost Array
Description
In a forgotten realm, a group of adventurers stumbles upon a set of mysterious scrolls hidden deep within an ancient library. These scrolls hold the secrets of a powerful numerical array that controls the magic of the realm. However, the scrolls have been damaged over time, and only fragments remain. Specifically, the adventurers discover a sequence of numbers representing the products of adjacent elements of an unknown array .
The original array consists of integers where for . The only information remaining on the scrolls is a sequence of integers , which are unordered products of adjacent elements from . In other words:
$$\{b_1, b_2, \dots, b_{n-1}\} = \{a_1 \times a_2, a_2 \times a_3, \dots, a_{n-1} \times a_n\}$$Your task is to help the adventurers reconstruct one possible original array . If there are multiple valid arrays that could result in the same sequence , you may output any of them.
Input Format
The first line contains a single integer , representing the length of the array . The second line contains space-separated integers , representing the products of adjacent elements in the array .
Output Format
If there is no such array , then print No on a line. Otherwise, print Yes on the first line. Then, output space-separated integers on the second line, where $\{b_1, b_2, \dots, b_{n-1}\} = \{a_1 \times a_2, a_2 \times a_3, \dots, a_{n-1} \times a_n\}$.
8
42 32 84 54 48 40 16
Yes
5 8 4 21 2 8 6 9
6
45 4 5 4 3
Yes
3 1 4 1 5 9
2
3246
No
Hint
- .
- for
- for
京公网安备 11011102002149号