結果

問題 No.1939 Numbered Colorful Balls
ユーザー 👑 tatyamtatyam
提出日時 2022-04-12 00:25:35
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 3,319 ms
コンパイル使用メモリ 252,956 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 05:51:27
合計ジャッジ時間 5,637 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 34 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 33 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 15 ms
4,376 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 7 ms
4,376 KB
testcase_19 AC 13 ms
4,376 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 8 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 8 ms
4,380 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 27 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 4 ms
4,376 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