結果

問題 No.2544 Many RMQ Problems
ユーザー momoyuumomoyuu
提出日時 2023-11-24 23:39:53
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 296 ms / 2,000 ms
コード長 804 bytes
コンパイル時間 2,469 ms
コンパイル使用メモリ 119,416 KB
実行使用メモリ 11,332 KB
最終ジャッジ日時 2023-11-24 23:40:03
合計ジャッジ時間 8,157 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
11,332 KB
testcase_01 AC 140 ms
11,332 KB
testcase_02 AC 140 ms
11,332 KB
testcase_03 AC 293 ms
11,332 KB
testcase_04 AC 275 ms
11,332 KB
testcase_05 AC 263 ms
11,332 KB
testcase_06 AC 282 ms
11,332 KB
testcase_07 AC 204 ms
11,332 KB
testcase_08 AC 166 ms
11,332 KB
testcase_09 AC 139 ms
11,332 KB
testcase_10 AC 141 ms
11,332 KB
testcase_11 AC 140 ms
11,332 KB
testcase_12 AC 140 ms
11,332 KB
testcase_13 AC 140 ms
11,332 KB
testcase_14 AC 140 ms
11,332 KB
testcase_15 AC 140 ms
11,332 KB
testcase_16 AC 140 ms
11,332 KB
testcase_17 AC 140 ms
11,332 KB
testcase_18 AC 140 ms
11,332 KB
testcase_19 AC 293 ms
11,332 KB
testcase_20 AC 293 ms
11,332 KB
testcase_21 AC 292 ms
11,332 KB
testcase_22 AC 296 ms
11,332 KB
testcase_23 AC 293 ms
11,332 KB
testcase_24 AC 140 ms
11,332 KB
testcase_25 AC 140 ms
11,332 KB
testcase_26 AC 293 ms
11,332 KB
testcase_27 AC 140 ms
11,332 KB
testcase_28 AC 293 ms
11,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<cassert>
#include<set>
#include<queue>
#include<cstdint>
#include<unordered_map>
using namespace std;
using ll = long long;


#include<atcoder/modint>
using mint = atcoder::modint998244353;


const int mx = 1e6;
mint fac[mx+1],ifac[mx+1];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    fac[0] = 1;
    for(int i = 1;i<=mx;i++) fac[i] = fac[i-1] * i;
    for(int i = 0;i<=mx;i++) ifac[i] = fac[i].inv();
    ll n,q;
    cin>>n>>q;
    mint ans = 0;
    mint tmp = 0;
    tmp = 1;
    for(int i = 1;i<=n;i++){
        ans += mint(n+1) * fac[i] * fac[n+1-i] * (fac[n]*ifac[i]*ifac[n-i]) / (i+1);
    }
    ans *= mint(q) * ( mint(n) * mint(n+1) *(mint(2).inv())).pow(q-1);
    cout<<ans.val()<<endl;
}

0