結果

問題 No.2351 Butterfly in Summer
ユーザー fiblonaria
提出日時 2023-06-20 04:04:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,469 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 82,192 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-06-27 15:19:57
合計ジャッジ時間 2,340 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

class mod_int: #素数を法とした自然数, または有理数を扱うことのできるクラス
    def __init__(self, value, mod):
        self.value = value % mod
        self.mod = mod
    def __neg__(self):
        return mod_int(-self.value, self.mod)
    def __add__(self, other):
        if type(other) == mod_int:
            return mod_int(self.value + other.value, self.mod)
        elif type(other) == int:
            return mod_int(self.value + other, self.mod)
        raise TypeError()
    def __sub__(self, other):
        return self + (-other)
    def __mul__(self, other):
        if type(other) == mod_int:
            return mod_int(self.value * other.value, self.mod)
        elif type(other) == int:
            return mod_int(self.value * other, self.mod)
        raise TypeError()
    def __truediv__(self, other):
        if type(other) in [mod_int, int]:
            return self * other ** (self.mod - 2)
        raise TypeError()
    def __pow__(self, other):
        if type(other) != int:
            raise TypeError()
        cur, ret = self.value, 1
        while other > 0:
            if other % 2:
                ret = (ret * cur) % self.mod
            other //= 2
            cur = (cur ** 2) % self.mod
        return mod_int(ret, self.mod)
    def __repr__(self):
        return str(self.value)
mod = 998244353
N_, K_ = map(int, input().split())
N = mod_int(N_, mod)
K = mod_int(K_, mod)
print(N * K * (K - 1) / (K ** N_))
0