結果

問題 No.1419 Power Moves
ユーザー chineristACchineristAC
提出日時 2021-03-05 22:33:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 598 ms / 2,000 ms
コード長 1,200 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 78,336 KB
最終ジャッジ日時 2024-10-07 03:12:20
合計ジャッジ時間 10,555 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,K = mi()
mod = 10**9 + 7

inv = 0
for inv in range(1,N+1):
    if inv*2 % N == 1:
        break

for i in range(N):
    if N%2==0:
        if i%2==0:
            print(0)
        else:
            amari = (pow(2,K,N//2)-1) % (N//2)
            t = ((pow(2,K,N)-1+i)) % N
            t //= 2
            if t <= amari:
                q = (pow(2,K,mod)-1-amari) % mod
            else:
                q = (pow(2,K,mod)-1-amari-(N//2)) % mod
            ans = (q * pow(N//2,mod-2,mod) + 1) % mod
            ans *= pow(2,K*(mod-2),mod)
            ans %= mod
            print(ans)
    else:
        amari = (pow(2,K,N)-1) % N
        t = ((pow(2,K,N)-1)+i) * inv % N
        if t <= amari:
            q = (pow(2,K,mod)-1-amari) % mod
        else:
            q = (pow(2,K,mod)-1-amari-N) % mod

        ans = (q * pow(N,mod-2,mod) + 1) % mod
        ans *= pow(2,K*(mod-2),mod)
        ans %= mod
        print(ans)
0