結果

問題 No.2881 Mod 2^N
ユーザー titia
提出日時 2024-09-26 01:34:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-09-26 01:34:53
合計ジャッジ時間 3,231 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from random import randint

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

if X==Y:
    print(0)
    exit()

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

def f(i,x):
    return (x*(1<<i) + 1)%(1<<N)

#print()

#for X in range(1,2**N):
#    now=X
#    for i in range(1,N+1):
#        to=f(i,now)
#        print(to,end=" ")
#    print()

ANS=[N]

LIST=[Y]

while LIST[-1]!=1:
    x=LIST[-1]-1
    while x%2==0:
        x//=2
    LIST.append(x)

LIST.reverse()

for i in range(len(LIST)-1):
    ind=-1
    for j in range(1,N+1):
        if LIST[i+1]==f(j,LIST[i]):
            ind=j
            break
    ANS.append(ind)

print(len(ANS))
print(*ANS)

            
        
0