結果

問題 No.3476 {2^n-1}-gon
コンテスト
ユーザー detteiuu
提出日時 2026-03-20 22:17:42
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 517 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 139 ms
コンパイル使用メモリ 85,336 KB
実行使用メモリ 61,028 KB
最終ジャッジ日時 2026-03-20 22:17:47
合計ジャッジ時間 1,400 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from sys import stdin
input = stdin.readline

MOD = 998244353

def inverse(n, d):
    return n * pow(d, -1, MOD) % MOD

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

top = 1
s = (pow(2, N-1, MOD)-1)%MOD
bottom = 1
for i in range(1, M):
    top *= s-i+1
    top %= MOD
    bottom *= i
    bottom %= MOD

top2 = 1
s2 = (pow(2, N, MOD)-1)%MOD
bottom2 = 1
for i in range(1, M+1):
    top2 *= s2-i+1
    top2 %= MOD
    bottom2 *= i
    bottom2 %= MOD

print((inverse(top2, bottom2) - inverse(top, bottom)*(pow(2, N, MOD)-1)%MOD)%MOD)
0