結果

問題 No.1871 divisXor
ユーザー hir355hir355
提出日時 2022-03-11 22:52:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,206 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 81,784 KB
実行使用メモリ 53,364 KB
最終ジャッジ日時 2023-10-23 19:14:40
合計ジャッジ時間 4,015 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,364 KB
testcase_01 AC 37 ms
53,364 KB
testcase_02 AC 38 ms
53,364 KB
testcase_03 AC 38 ms
53,364 KB
testcase_04 AC 38 ms
53,364 KB
testcase_05 AC 38 ms
53,364 KB
testcase_06 AC 38 ms
53,364 KB
testcase_07 AC 37 ms
53,364 KB
testcase_08 AC 37 ms
53,364 KB
testcase_09 AC 37 ms
53,364 KB
testcase_10 AC 38 ms
53,364 KB
testcase_11 AC 37 ms
53,364 KB
testcase_12 AC 38 ms
53,364 KB
testcase_13 AC 37 ms
53,364 KB
testcase_14 AC 37 ms
53,364 KB
testcase_15 AC 38 ms
53,364 KB
testcase_16 AC 38 ms
53,364 KB
testcase_17 AC 37 ms
53,364 KB
testcase_18 AC 37 ms
53,364 KB
testcase_19 AC 37 ms
53,364 KB
testcase_20 AC 37 ms
53,364 KB
testcase_21 AC 37 ms
53,364 KB
testcase_22 AC 37 ms
53,364 KB
testcase_23 AC 37 ms
53,364 KB
testcase_24 AC 37 ms
53,364 KB
testcase_25 AC 38 ms
53,364 KB
testcase_26 AC 38 ms
53,364 KB
testcase_27 AC 37 ms
53,364 KB
testcase_28 AC 37 ms
53,364 KB
testcase_29 AC 38 ms
53,364 KB
testcase_30 AC 37 ms
53,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n == 0:
    print(-1)
    exit(0)
if n < 10:
    ans = [[-1], [1], [2, 1], [2], [3], [5, 2], [5], [5, 1], [10], [10, 1]]
    print(len(ans[n]))
    print(*(ans[n]))
    exit(0)
ans = []
p = [2, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459, 536870923, 1073741827, 2147483659, 4294967311, 8589934609, 17179869209, 34359738421, 68719476767, 137438953481, 274877906951, 549755813911, 1099511627791, 2199023255579, 4398046511119, 8796093022237, 17592186044423, 35184372088891, 70368744177679, 140737488355333, 281474976710677, 562949953421381, 1125899906842679, 2251799813685269, 4503599627370517, 9007199254740997, 18014398509482143, 36028797018963971, 72057594037928017, 144115188075855881, 288230376151711813, 576460752303423619, 1152921504606847009]
p.reverse()
idx = 0
tmp = 0
while n > 1:
    x = -1
    while idx < len(p) and len(bin(p[idx] + 1)) == len(bin(n)):
        x = p[idx]
        idx += 1
    if x != -1:
        ans.append(x)
        n ^= x + 1
    else:
        idx += 1
if n == 1:
    ans.append(1)
print(len(ans))
print(*ans)
0