結果

問題 No.2881 Mod 2^N
ユーザー 👑 loop0919
提出日時 2025-09-03 22:43:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 54,016 KB
最終ジャッジ日時 2025-09-03 22:43:47
合計ジャッジ時間 3,528 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import pairwise

N, X, Y = map(int, input().split())

if Y % 2 == 0:
    if X == Y:
        print(0)
        print()
    else:
        print(-1)
    exit()

op = []
op.append(N)

idxes = [i + 1 for i in range(N) if (Y >> i) & 1][::-1]

for next_i, curr_i in pairwise(idxes):
    op.append(next_i - curr_i)

print(len(op))
print(*op)

# test
_x = X
for cmd in op:
    _x = (_x * 2**cmd + 1) % 2**N

assert _x == Y, f"{_x=}, {Y=}"
0