結果

問題 No.1939 Numbered Colorful Balls
ユーザー tatyamtatyam
提出日時 2022-04-12 00:25:35
言語 C++23(draft)
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 3,249 ms
使用メモリ 3,980 KB
最終ジャッジ日時 2023-01-08 20:57:29
合計ジャッジ時間 5,163 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 62 ms
3,780 KB
testcase_01 AC 2 ms
3,556 KB
testcase_02 AC 3 ms
3,892 KB
testcase_03 AC 49 ms
3,892 KB
testcase_04 AC 2 ms
3,396 KB
testcase_05 AC 42 ms
3,896 KB
testcase_06 AC 4 ms
3,820 KB
testcase_07 AC 5 ms
3,520 KB
testcase_08 AC 3 ms
3,468 KB
testcase_09 AC 12 ms
3,624 KB
testcase_10 AC 2 ms
3,604 KB
testcase_11 AC 4 ms
3,540 KB
testcase_12 AC 3 ms
3,564 KB
testcase_13 AC 2 ms
3,412 KB
testcase_14 AC 12 ms
3,720 KB
testcase_15 AC 6 ms
3,700 KB
testcase_16 AC 24 ms
3,504 KB
testcase_17 AC 14 ms
3,548 KB
testcase_18 AC 11 ms
3,720 KB
testcase_19 AC 22 ms
3,580 KB
testcase_20 AC 3 ms
3,520 KB
testcase_21 AC 7 ms
3,588 KB
testcase_22 AC 2 ms
3,636 KB
testcase_23 AC 3 ms
3,392 KB
testcase_24 AC 9 ms
3,716 KB
testcase_25 AC 3 ms
3,440 KB
testcase_26 AC 47 ms
3,980 KB
testcase_27 AC 1 ms
3,448 KB
testcase_28 AC 1 ms
3,448 KB
testcase_29 AC 4 ms
3,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> L(M);
    for(int& l : L) cin >> l;
    sort(L.begin(), L.end());
    vector<Modint> f(N + 1);
    f[0] = 1;
    vector<Modint> inv(N + 2);
    inv[1] = 1;
    for(int i = 2; i <= N + 1; i++) inv[i] = inv[Modint::mod() % i] * -Modint::raw(Modint::mod() / i);
    for(int n = 1; n <= N; n++){
        for(int l : L){
            if(l > n) break;
            f[n] += f[n - l] * (int64_t(N) * l + l * 2 - n);
        }
        f[n] *= inv[n];
    }
    cout << (f[N] * inv[N + 1]).val() << endl;
}
0