結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using mint = atcoder::modint998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, v;
    cin >> n >> k;
    mint p0 = 1, p1 = 1, coef = 1;
    for(int i = 0; i < n; i++){
        cin >> v;
        if(v < k) continue;
        coef *= mint::raw(v).inv();
        p0 *= mint::raw(k);
        p1 *= mint::raw(k - 1);
    }
    cout << ((p0 - p1) * coef).val() << '\n';
}
0