結果

問題 No.3095 Many Min Problems
ユーザー LyricalMaestro
提出日時 2025-05-10 18:42:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 444 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 82,904 KB
実行使用メモリ 63,532 KB
最終ジャッジ日時 2025-05-10 18:42:43
合計ジャッジ時間 8,955 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/3095

MOD = 998244353

def main():
    N, M = map(int, input().split())

    m_n = pow(M, N, MOD)

    answer = N
    for m in range(2, M + 1):
        p = ((M + 1 - m) * pow(M, MOD -2, MOD)) % MOD

        x1 = pow(p, N, MOD)
        x1 = (1 - x1) % MOD
        x2 = (1 - p) % MOD

        ans = (x1 * p) % MOD
        ans *= pow(x2, MOD - 2, MOD)
        ans %= MOD

        answer += ans
    
    answer *= m_n
    answer %= MOD
    print(answer)









if __name__ == '__main__':
    main()
0