あなたはコインをN個積みました。それぞれのB 1 、B 2 、…、B
N
パイルを別々のグループに分けることに決めました。コインを受け取る人の数は素数でなければならず、各人に与えられる金額は各パイルごとに異なっていなければならない。
入力:N、B <1>、B <2>、…、B (各個々のパイルにおけるコインの量)。
出力:コインを受け取る人数(素数)をNPとし、NP 1 、NP 2 、…、NP
N これが不可能な場合は、( 0
、 -1
、
None
、 []
"impossible"
)、エラーが発生します。
例:
3
7 8 9
Output: 7 2 3
(7/7 = 1)≠(8/2 = 4)≠(9/3 =
3)であることに注目してください。また、7が7を均等に割り切れる唯一の素数であるため、8と2、 )。
ベストアンサー
05AB1E, 13 bytes
Ò.»â€˜ʒ÷DÙQ}θ
私のピースの答えのポート。
-
Ò
gets the prime factÒrs of
each. -
.»
folds a dyadic command,â
(cârtesiân product) between each
two elements in the list from right to left with opposite
right/left operands. -
€˜
flattens €ach. -
ʒ...}
filtʒrs those which satisfy
the following condition:-
÷
pairwise integer division with the input. -
D
Duplicate (pushes two copies of
the item to the stack). -
Ù
removes duplicate elements, keeping a
ÙniqÙe occurrence of each
element. -
Q
checks for eQuality.
-
-
θ
gets the last element.