結果

問題 No.2544 Many RMQ Problems
ユーザー pockynypockyny
提出日時 2023-11-27 05:14:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,313 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 72,632 KB
実行使用メモリ 19,272 KB
最終ジャッジ日時 2023-11-27 05:14:47
合計ジャッジ時間 3,304 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
19,272 KB
testcase_01 AC 35 ms
19,272 KB
testcase_02 AC 35 ms
19,272 KB
testcase_03 AC 41 ms
19,272 KB
testcase_04 AC 41 ms
19,272 KB
testcase_05 AC 40 ms
19,272 KB
testcase_06 AC 41 ms
19,272 KB
testcase_07 AC 38 ms
19,272 KB
testcase_08 AC 35 ms
19,272 KB
testcase_09 AC 35 ms
19,272 KB
testcase_10 AC 35 ms
19,272 KB
testcase_11 AC 35 ms
19,272 KB
testcase_12 AC 35 ms
19,272 KB
testcase_13 AC 35 ms
19,272 KB
testcase_14 AC 35 ms
19,272 KB
testcase_15 AC 35 ms
19,272 KB
testcase_16 AC 35 ms
19,272 KB
testcase_17 AC 35 ms
19,272 KB
testcase_18 AC 35 ms
19,272 KB
testcase_19 AC 42 ms
19,272 KB
testcase_20 AC 42 ms
19,272 KB
testcase_21 AC 42 ms
19,272 KB
testcase_22 AC 42 ms
19,272 KB
testcase_23 AC 42 ms
19,272 KB
testcase_24 AC 35 ms
19,272 KB
testcase_25 AC 34 ms
19,272 KB
testcase_26 AC 42 ms
19,272 KB
testcase_27 AC 35 ms
19,272 KB
testcase_28 AC 42 ms
19,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
const int MX = 1000010;
mint f[MX],inv[MX],fi[MX];
constexpr ll mod = 998244353;
void solve(){
    inv[1] = 1;
    for(int i=2;i<MX;i++){
        inv[i] = mod - (mod/i)*inv[mod%i];
    }
    f[0] = fi[0] = 1;
    for(int i=1;i<MX;i++){
        f[i] = f[i-1]*i;
        fi[i] = fi[i-1]*inv[i];
    }
}

mint nck(ll n, ll k){
    if(n<0 || k<0 || n<k) return 0;
    return f[n]*fi[k]*fi[n-k];
}

mint pw(mint a,ll x){
    mint ret = 1;
    while(x){
        if(x&1) (ret *= a);
        (a *= a); x /= 2;
    }
    return ret;
}

mint a[1000010];
int main(){
    solve();
    ll i,n,q; cin >> n >> q;
    // for(int i=1;i<=n;i++){
    //     mint sum = 0;
    //     for(int x=1;x<=i;x++){
    //         for(int l=0;l<i;l++){
    //             for(int r=l;r<i;r++){
    //                 sum += nck(i - x + 1,r - l + 1)*f[r - l + 1]*f[i - (r - l + 1)];   
    //             }
    //         }
    //     }
    //     cout << sum.val() << " ";
    // }
    // cout << endl;
    // 1 8 58 444 3708 33984 341136 3733920 44339040 568356480
    a[0] = 0;
    for(i=1;i<=n;i++) a[i] = a[i - 1]*(i + 2) + i*f[i];
    cout << (a[n]*q*pw((n*(n + 1)/2),q - 1)).val() << endl;
}
0