아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

In Search of the Lost Array

시간 제한2초메모리 제한1024 MB

요약
인접한 원소들의 곱을 모아 놓은 수열 b가 주어질 때, 각 원소가 1 이상 100 이하인 배열 A를 복원하거나 그러한 배열이 없음을 판정한다.
난이도

보통10점 중 6점

유형
백트래킹, 완전 탐색, 정수론
정답자
아직 제출이 없습니다

문제

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 AA.

The original array AA consists of nn integers a_1,a_2,…,a_na\_1, a\_2,\dots ,a\_n where 1≤a_i≤1001 ≤ a\_i ≤ 100 for 1≤i≤n1 ≤ i ≤ n. The only information remaining on the scrolls is a sequence of n−1n - 1 integers b_1,b_2,…,b_n−1b\_1, b\_2,\dots ,b\_{n-1}, which are unordered products of adjacent elements from AA. In other words: b_1,b_2,…,b_n−1=a_1×a_2,a_2×a_3,…,a_n−1×a_n\\{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 AA. If there are multiple valid arrays AA that could result in the same sequence bb, you may output any of them.

입력

The first line contains a single integer nn, representing the length of the array AA. The second line contains n−1n - 1 space-separated integers b_1,b_2,…,b_n−1b\_1, b\_2,\dots ,b\_{n-1}, representing the products of adjacent elements in the array AA.

출력

If there is no such array AA, then print No on a line. Otherwise, print Yes on the first line. Then, output nn space-separated integers a_1,a_2,…,a_na\_1, a\_2,\dots ,a\_n on the second line, where b_1,b_2,…,b_n−1=a_1×a_2,a_2×a_3,…,a_n−1×a_n\\{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\\}.

제한

  • 1<n≤181 < n ≤ 18. 1≤a_i≤1001 ≤ a\_i ≤ 100 for i∈1,2,…,ni \in \\{1, 2,\dots ,n\\}
  • 1≤b_i≤100001 ≤ b\_i ≤ 10000 fori∈1,2,…,n−1i \in \\{1, 2,\dots ,n-1\\}

예제3

  1. 예제 1

    입력
    8
    42 32 84 54 48 40 16
    
    예상 출력
    Yes
    5 8 4 21 2 8 6 9
    
  2. 예제 2

    입력
    6
    45 4 5 4 3
    
    예상 출력
    Yes
    3 1 4 1 5 9
    
  3. 예제 3

    입력
    2
    3246
    
    예상 출력
    No