結果

問題 No.1419 Power Moves
ユーザー ygd.
提出日時 2021-03-05 23:59:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 325,236 KB
最終ジャッジ日時 2024-10-07 06:15:08
合計ジャッジ時間 8,401 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split()); MOD = pow(10,9)+7
MAX = pow(2,K)-1

if N%2 == 1:
    youso = (pow(2,K,2*N*MOD)-1)//(2*N)
    ans = [youso]*N
    #ans = [(MAX//(2*N))%MOD]*N
    amari = (pow(2,K,2*N*MOD)-1)%(2*N)
    #amari =  MAX%(2*N)
    for i in range(N):
        #ans[i] += MAX//(2*N)
        if i%2 == 1 and amari >= i:
            ans[i] += 1
        if i%2 == 0 and amari >= i + N:
            ans[i] += 1

else:
    youso = (pow(2,K,N*MOD)-1)//N
    ans = [youso]*N
    #ans = [(MAX//N)%MOD]*N
    amari = (pow(2,K,N*MOD)-1)%N
    #amari = MAX%N
    for i in range(N):
        if i%2 == 1:
            if amari >= i:
                ans[i] += 1
        else:
            ans[i] = 0
#print(ans)
for i in range(N):
    P = ans[i] + ans[(N-i)%N]
    #print(i,P)
    ret = P*pow(pow(2,K,MOD),MOD-2,MOD)
    print(ret%MOD)
0