結果
| 問題 | No.3153 probability max K | 
| コンテスト | |
| ユーザー |  遭難者 | 
| 提出日時 | 2025-05-20 21:52:19 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 73 ms / 2,000 ms | 
| コード長 | 1,250 bytes | 
| コンパイル時間 | 5,545 ms | 
| コンパイル使用メモリ | 332,304 KB | 
| 実行使用メモリ | 6,272 KB | 
| 最終ジャッジ日時 | 2025-05-20 21:52:27 | 
| 合計ジャッジ時間 | 7,755 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::modint998244353;
using namespace std;
using ld = long double;
#undef long
#define long long long
#define ll long
#define vec vector
#define rep(i, n) for (long i = 0; i < n; i++)
#define all(a) begin(a), end(a)
#define sz(a) (int)(a).size()
template <typename T>
bool chmin(T &x, T y)
{
    if (y < x)
    {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
bool chmax(T &x, T y)
{
    if (x < y)
    {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> a)
{
    const int n = a.size();
    rep(i, n)
    {
        os << a[i];
        if (i + 1 != n)
            os << " ";
    }
    return os;
}
void solve()
{
    int n, k;
    cin >> n >> k;
    mint c1 = 1, c2 = 1;
    rep(i, n)
    {
        int a;
        cin >> a;
        mint aa = mint(a).inv();
        if (a >= k)
            c1 *= k * aa;
        if (a >= k - 1)
            c2 *= (k - 1) * aa;
    }
    cout << (c1 - c2).val() << endl;
}
int main()
{
    cin.tie(0)->sync_with_stdio(0), cout.tie(0);
    cout << fixed << setprecision(20);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}
            
            
            
        