結果

問題 No.2081 Make a Test Case of GCD Subset
ユーザー flygonflygon
提出日時 2022-09-26 20:20:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 78,496 KB
最終ジャッジ日時 2023-08-24 03:02:55
合計ジャッジ時間 8,016 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
78,220 KB
testcase_01 AC 113 ms
78,212 KB
testcase_02 AC 113 ms
78,396 KB
testcase_03 AC 111 ms
78,496 KB
testcase_04 AC 112 ms
78,364 KB
testcase_05 AC 113 ms
78,360 KB
testcase_06 AC 110 ms
78,000 KB
testcase_07 AC 113 ms
78,404 KB
testcase_08 AC 114 ms
78,012 KB
testcase_09 AC 114 ms
78,400 KB
testcase_10 AC 111 ms
78,316 KB
testcase_11 AC 113 ms
78,232 KB
testcase_12 AC 114 ms
78,216 KB
testcase_13 AC 113 ms
78,268 KB
testcase_14 AC 113 ms
78,268 KB
testcase_15 AC 111 ms
78,468 KB
testcase_16 AC 107 ms
78,256 KB
testcase_17 AC 108 ms
78,244 KB
testcase_18 AC 112 ms
78,208 KB
testcase_19 AC 112 ms
78,232 KB
testcase_20 AC 106 ms
78,128 KB
testcase_21 AC 72 ms
71,240 KB
testcase_22 AC 110 ms
78,472 KB
testcase_23 AC 114 ms
78,128 KB
testcase_24 AC 112 ms
78,396 KB
testcase_25 AC 114 ms
78,136 KB
testcase_26 AC 113 ms
77,960 KB
testcase_27 AC 115 ms
78,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

m = int(input())
if m == 0:
  print(1)
  print(1)
  exit()
def e(n): #O(NloglogN)
  l = [True]*(n+1)
  l[0] = False
  l[1] = False
  for i in range(2,n):
    if l[i]:
      for p in range(i+i,n+1,i):
        l[p] = False
  return l

t = e(10**5)
pn = []
for i in range(2, 10**5):
  if t[i]:
    pn.append(i)

now = 0
left = m
bits = []
while left:
  if left & 1:
    bits.append(now)
  left >>= 1
  now += 1

from collections import deque
que = deque(pn)
koho = []
for i in bits[::-1]:
  pn = que.popleft()
  for j in range(i):
    koho.append(pn)
  koho.append(que.pop())

ans = set()
koho.sort(key = lambda x:-x)
for i in koho:
  if i not in ans:
    ans.add(i)
  else:
    ans.add(i*que.popleft())
print(len(ans))
print(*ans)

0