Logo
(追記) (追記ここまで)

32457번 - In Search of the Lost Array 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB57454078.431%

문제

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 $A$.

The original array $A$ consists of $n$ integers $a_1, a_2,\dots ,a_n$ where 1ドル ≤ a_i ≤ 100$ for 1ドル ≤ i ≤ n$. The only information remaining on the scrolls is a sequence of $n - 1$ integers $b_1, b_2,\dots ,b_{n-1},ドル which are unordered products of adjacent elements from $A$. 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 $A$. If there are multiple valid arrays $A$ that could result in the same sequence $b,ドル you may output any of them.

입력

The first line contains a single integer $n,ドル representing the length of the array $A$. The second line contains $n - 1$ space-separated integers $b_1, b_2,\dots ,b_{n-1},ドル representing the products of adjacent elements in the array $A$.

출력

If there is no such array $A,ドル then print No on a line. Otherwise, print Yes on the first line. Then, output $n$ space-separated integers $a_1, a_2,\dots ,a_n$ 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\}$.

제한

  • 1ドル < n ≤ 18$. 1ドル ≤ a_i ≤ 100$ for $i \in \{1, 2,\dots ,n\}$
  • 1ドル ≤ b_i ≤ 10000$ for$i \in \{1, 2,\dots ,n-1\}$

예제 입력 1

8
42 32 84 54 48 40 16

예제 출력 1

Yes
5 8 4 21 2 8 6 9

예제 입력 2

6
45 4 5 4 3

예제 출력 2

Yes
3 1 4 1 5 9

예제 입력 3

2
3246

예제 출력 3

No

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2024 I번

  • 스페셜 저지를 만든 사람: jhnah917
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /