結果
問題 |
No.3153 probability max K
|
ユーザー |
|
提出日時 | 2025-05-20 22:33:31 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,192 ms / 2,000 ms |
コード長 | 3,755 bytes |
コンパイル時間 | 552 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 32,596 KB |
最終ジャッジ日時 | 2025-06-25 16:45:34 |
合計ジャッジ時間 | 24,566 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
class Modint: mod = 0 has_been_set = False def __init__(self, v=0, m=None): if m != None: assert m >= 1 assert not Modint.has_been_set Modint.mod = m Modint.has_been_set = True assert Modint.has_been_set self._v = v if 0 <= v < Modint.mod else v % Modint.mod def __add__(self, other): if isinstance(other, Modint): res = self._v + other._v if res > Modint.mod: res -= Modint.mod else: res = self._v + other return Modint(res) def __sub__(self, other): if isinstance(other, Modint): res = self._v - other._v if res < 0: res += Modint.mod else: res = self._v - other return Modint(res) def __mul__(self, other): if isinstance(other, Modint): return Modint(self._v * other._v) else: return Modint(self._v * other) def __floordiv__(self, other): if isinstance(other, Modint): other = other._v inv = pow(other, -1, Modint.mod) return Modint(self._v * inv) def __pow__(self, other): assert isinstance(other, int) and other >= 0 return Modint(pow(self._v, other, Modint.mod)) def __radd__(self, other): return Modint(self._v + other) def __rsub__(self, other): return Modint(other - self._v) def __rmul__(self, other): return Modint(self._v * other) def __rfloordiv__(self, other): inv = pow(self._v, -1, Modint.mod) return Modint(other * inv) def __iadd__(self, other): if isinstance(other, Modint): self._v += other._v if self._v >= Modint.mod: self._v -= Modint.mod else: self._v += other if self._v < 0 or self._v >= Modint.mod: self._v %= Modint.mod return self def __isub__(self, other): if isinstance(other, Modint): self._v -= other._v if self._v < 0: self._v += Modint.mod else: self._v -= other if self._v < 0 or self._v >= Modint.mod: self._v %= Modint.mod return self def __imul__(self, other): if isinstance(other, Modint): self._v *= other._v else: self._v *= other if self._v < 0 or self._v >= Modint.mod: self._v %= Modint.mod return self def __ifloordiv__(self, other): if isinstance(other, Modint): other = other._v inv = pow(other, -1, Modint.mod) self._v *= inv if self._v > Modint.mod: self._v %= Modint.mod return self def __ipow__(self, other): assert isinstance(other, int) and other >= 0 self._v = pow(self._v, other, Modint.mod) return self def __eq__(self, other): if isinstance(other, Modint): return self._v == other._v else: if other < 0 or other >= Modint.mod: other %= Modint.mod return self._v == other def __ne__(self, other): if isinstance(other, Modint): return self._v != other._v else: if other < 0 or other >= Modint.mod: other %= Modint.mod return self._v != other def __str__(self): return str(self._v) def __repr__(self): return str(self._v) def __int__(self): return self._v Modint(m=998244353) N, K = map(int, input().split()) A = list(map(int, input().split())) def solve(x): ans = Modint(1) for a in A: ans *= x ans //= max(x, a) return ans print(solve(K) - solve(K-1))