結果
| 問題 |
No.2544 Many RMQ Problems
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-24 22:05:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 394 ms / 2,000 ms |
| コード長 | 667 bytes |
| コンパイル時間 | 1,425 ms |
| コンパイル使用メモリ | 167,760 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-26 09:22:50 |
| 合計ジャッジ時間 | 6,123 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 |
ソースコード
#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;
}