結果

問題 No.1528 Not 1
ユーザー YoujiO3YoujiO3
提出日時 2021-06-04 22:51:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 763 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,948 KB
最終ジャッジ日時 2024-04-30 11:08:37
合計ジャッジ時間 3,701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
17,948 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import ceil, gcd
import sys
n = int(input())
if n == 1 or n == 2:
  print(-1)
  sys.exit()
l = ceil(n/2)
# s_list = list(range(3, n+1, 1))
# print(f'l:{l}')
r = []
m = 2
s = 2
r.append(2)
while len(r) < l:
  # s_list.sort()
  # for i in s_list:
  for i in range(s, n+1):
    if len(r) == 0:
      m += 1
      r.append(m)
      if m > n:
        print(-1)
        sys.exit()
      else:
        continue
    if gcd(r[-1], i) != 1 and not i in r:
      # print(f'push {i}')
      r.append(i)
      s = 2
      # s_list.remove(i)
      break
    elif i == n:
      s = r.pop()
      # print(f'pop {s}')
      if s == n:
        print(-1)
        sys.exit()
      else:
        s += 1
        # s_list.append(s)
re = [str(i) for i in r]
print(' '.join(re))
0