結果

問題 No.3153 probability max K
ユーザー Naru820
提出日時 2025-05-20 21:42:23
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 2,909 ms
コンパイル使用メモリ 274,328 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-20 21:42:32
合計ジャッジ時間 8,421 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 998244353;
ll n,k,a;
ll power(ll x, ll y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return res;
}
int main(){
    cin >> n >> k;
    ll pk = 1,qk = 1;
    for(int i = 0; i < n; i++){
        cin >> a;
        ll inv = power(a, mod - 2);
        pk *= inv * min(a,k)  % mod;
        pk %= mod;
        qk *= inv * min(a,k -1) % mod;
        qk %= mod;
    }
    ll ans = (pk - qk + mod) % mod;
    cout << ans << endl;
}
0