結果

問題 No.1670 Many Gacha
ユーザー karinohitokarinohito
提出日時 2021-09-03 23:56:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 1,785 ms
コンパイル使用メモリ 171,336 KB
実行使用メモリ 13,904 KB
最終ジャッジ日時 2023-08-22 02:24:54
合計ジャッジ時間 6,789 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 175 ms
13,316 KB
testcase_09 AC 181 ms
13,588 KB
testcase_10 AC 179 ms
13,516 KB
testcase_11 AC 40 ms
4,384 KB
testcase_12 AC 43 ms
4,376 KB
testcase_13 AC 39 ms
4,612 KB
testcase_14 AC 138 ms
10,516 KB
testcase_15 AC 110 ms
8,356 KB
testcase_16 AC 128 ms
9,984 KB
testcase_17 AC 67 ms
5,600 KB
testcase_18 AC 110 ms
8,620 KB
testcase_19 AC 71 ms
6,028 KB
testcase_20 AC 162 ms
11,932 KB
testcase_21 AC 118 ms
9,100 KB
testcase_22 AC 120 ms
9,084 KB
testcase_23 AC 158 ms
12,272 KB
testcase_24 AC 84 ms
8,052 KB
testcase_25 AC 127 ms
9,860 KB
testcase_26 AC 67 ms
6,196 KB
testcase_27 AC 65 ms
6,032 KB
testcase_28 AC 57 ms
5,640 KB
testcase_29 AC 115 ms
9,396 KB
testcase_30 AC 74 ms
6,688 KB
testcase_31 AC 88 ms
7,772 KB
testcase_32 AC 69 ms
6,416 KB
testcase_33 AC 171 ms
12,812 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 48 ms
4,608 KB
testcase_36 AC 187 ms
13,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
ll mod=998244353;
ll inva(ll N) {
    ll a = N, b = mod, c = 1, d = 0;
    while (b > 0) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        c -= t * d;
        swap(c, d);

    }
    c %= mod;
    if (c < 0)c += mod;
    return c;

}//割り算時に使う逆元を求める.


int main() {
    ll N,M;
    cin>>N>>M;
    set<ll> A;
    rep(i,M){
        ll Ai;
        cin>>Ai;
        A.insert(Ai);
    }
    vll B(N);
    ll an=0;
    rep(i,N){
        B[i]=*A.lower_bound(i+1);
        an+=B[i]*inva(N-i);
        an%=mod;

    }
    cout<<an<<endl;
    
}
0