東京海上日動 プログラミングコンテスト2021 (AtCoder Regular Contest 122)
翻译中…
Problem Statement
翻译中…
We have a sequence of $N$ positive integers: $A_1,A_2,\cdots,A_N$. You are to rearrange these integers into another sequence $x_1,x_2,\cdots,x_N$, where $x$ must satisfy the following condition:
翻译中…
- Let us define
$y_i=\operatorname{LCM}(x_1,x_2,\cdots,x_i)$, where the function$\operatorname{LCM}$returns the least common multiple of the given integers. Then,$y$is strictly increasing. In other words,$y_1<y_2<\cdots<y_N$holds.
翻译中…
Determine whether it is possible to form a sequence $x$ satisfying the condition, and show one such sequence if it is possible.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 100$$2 \leq A_1 < A_2 \cdots < A_N \leq 10^{18}$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 \cdots A_N
翻译中…
Output
翻译中…
If it is possible to form a sequence $x$ satisfying the condition, print your answer in the following format:
翻译中…
Yes
x_1 x_2 \cdots x_N
翻译中…
If it is impossible, print No.
翻译中…
样例
Input #1
3
3 4 6
Output #1
Yes
3 6 4
For $x=(3,6,4)$, we have:
- $y_1=\operatorname{LCM}(3)=3$
- $y_2=\operatorname{LCM}(3,6)=6$
- $y_3=\operatorname{LCM}(3,6,4)=12$
Here, $y_1
Input #2
3
2 3 6
Output #2
No
No permutation of $A$ would satisfy the condition.
Input #3
10
922513 346046618969 3247317977078471 4638516664311857 18332844097865861 81706734998806133 116282391418772039 134115264093375553 156087536381939527 255595307440611247
Output #3
Yes
922513 346046618969 116282391418772039 81706734998806133 255595307440611247 156087536381939527 134115264093375553 18332844097865861 3247317977078471 4638516664311857
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。