結果

問題 No.986 Present
ユーザー maspy
提出日時 2020-02-13 00:01:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 50,228 KB
最終ジャッジ日時 2024-10-04 07:44:11
合計ジャッジ時間 18,881 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N, M = map(int, read().split())

MOD = 998244353

def cumprod(A, MOD = MOD):
    L = len(A); Lsq = int(L**.5+1)
    A = np.resize(A, Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        A[:,n] *= A[:,n-1]; A[:,n] %= MOD
    for n in range(1,Lsq):
        A[n] *= A[n-1,-1]; A[n] %= MOD
    return A.ravel()[:L]
def make_power(a, L, MOD=MOD):
    B = L.bit_length()
    x = np.empty((1<<B), np.int64)
    x[0] = 1
    for n in range(B):
        x[1<<n:1<<(n+1)] = x[:1<<n] * a % MOD
        a *= a; a %= MOD
    x = x[:L]
    x.flags.writeable = False
    return x

pow_2 = make_power(2, M + 10, MOD)

answer = [0,0,0]

answer[0] = pow_2[N]

x = pow_2[M] - pow_2[:N]
answer[1] = cumprod(x)[-1]

x = pow_2[N] - pow_2[:N]
answer[2] = answer[1] * pow(int(cumprod(x)[-1]), MOD-2, MOD) % MOD

print(*answer)
0