結果

問題 No.2351 Butterfly in Summer
ユーザー fiblonariafiblonaria
提出日時 2023-06-20 04:04:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,469 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 86,544 KB
実行使用メモリ 71,420 KB
最終ジャッジ日時 2023-09-09 22:50:09
合計ジャッジ時間 3,691 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,984 KB
testcase_01 AC 75 ms
71,144 KB
testcase_02 AC 72 ms
71,168 KB
testcase_03 AC 71 ms
71,328 KB
testcase_04 AC 72 ms
71,244 KB
testcase_05 AC 70 ms
71,240 KB
testcase_06 AC 70 ms
71,176 KB
testcase_07 AC 71 ms
71,328 KB
testcase_08 AC 73 ms
70,968 KB
testcase_09 AC 70 ms
71,124 KB
testcase_10 AC 72 ms
71,272 KB
testcase_11 AC 75 ms
71,240 KB
testcase_12 AC 73 ms
71,116 KB
testcase_13 AC 73 ms
71,420 KB
testcase_14 AC 73 ms
71,156 KB
testcase_15 AC 72 ms
71,220 KB
testcase_16 AC 70 ms
71,280 KB
testcase_17 AC 70 ms
71,268 KB
testcase_18 AC 72 ms
71,264 KB
testcase_19 AC 72 ms
71,244 KB
testcase_20 AC 74 ms
71,176 KB
testcase_21 AC 75 ms
71,268 KB
testcase_22 AC 73 ms
71,280 KB
testcase_23 AC 73 ms
71,396 KB
権限があれば一括ダウンロードができます

ソースコード

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