結果

問題 No.2544 Many RMQ Problems
ユーザー maksimmaksim
提出日時 2023-11-24 22:05:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 543 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 167,392 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-24 22:06:05
合計ジャッジ時間 8,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 519 ms
6,676 KB
testcase_04 AC 456 ms
6,676 KB
testcase_05 AC 411 ms
6,676 KB
testcase_06 AC 479 ms
6,676 KB
testcase_07 AC 221 ms
6,676 KB
testcase_08 AC 95 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 517 ms
6,676 KB
testcase_20 AC 543 ms
6,676 KB
testcase_21 AC 519 ms
6,676 KB
testcase_22 AC 519 ms
6,676 KB
testcase_23 AC 521 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 7 ms
6,676 KB
testcase_26 AC 516 ms
6,676 KB
testcase_27 AC 7 ms
6,676 KB
testcase_28 AC 520 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define app push_back
const int p=998244353;
int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*u)%p;} else {int u=po(a,b-1);return (a*u)%p;}}
int inv(int x) {return po(x,p-2);}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,q;cin>>n>>q;
    int ans=1;
    for(int i=1;i<=n;++i) {ans*=i;ans%=p;} int o=n*(n+1)/2; o%=p;
    for(int i=0;i<q-1;++i) {ans*=o;ans%=p;}
    ans*=q;ans%=p;
    int s=0;
    for(int i=1;i<=n;++i) {s+=(((n+1)*(n-i+1))%p)*inv(i+1);s%=p;}
    ans*=s;ans%=p;
    cout<<ans;
    return 0;
}
0