結果

問題 No.1871 divisXor
ユーザー nasutarou1341
提出日時 2022-03-11 22:27:54
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 569 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 59,760 KB
最終ジャッジ日時 2024-09-22 12:59:14
合計ジャッジ時間 4,547 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def divisor(n):
  L, R = [1], [n]
  last = math.floor(n ** 0.5)
  for i in range(2, last + 1):
    if n % i == 0:
      L.append(i)
      if i != n // i:
        R.append(n // i)
  return sum(L + R[::-1])

N = int(input())

if N == 0:
  print(-1)
  exit()

a = []
while N > 7:
  b = N - 1
  while True:
    x = divisor(b)
    if len(bin(x)) == len(bin(N)):
      break
    b -= 1
  a.append(b)
  N ^= x

if N >= 4:
  a.append(3)
  N ^= 4
if N == 1:
  a.append(1)
elif N == 2:
  a.append(2)
  a.append(1)
elif N == 3:
  a.append(2)

print(len(a))
print(*a)

0