結果
| 問題 |
No.1967 Sugoroku Optimization
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2022-06-05 21:36:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 692 ms / 2,000 ms |
| コード長 | 662 bytes |
| コンパイル時間 | 1,967 ms |
| コンパイル使用メモリ | 196,536 KB |
| 最終ジャッジ日時 | 2025-01-29 18:37:43 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const int MOD=998244353;
ll dp[2020][2020];
ll modpow(ll x,ll n){
ll ans=1;
while(n){
if(n&1) ans=ans*x%MOD;
x=x*x%MOD;
n/=2;
}
return ans;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k;
cin>>n>>k;
rep(j,k) dp[n][j]=1;
for(int j=1;j<=k;j++){
vector<ll> S(n+2);
for(int i=0;i<=n;i++) S[i+1]=(S[i]+dp[i][j-1])%MOD;
for(int i=0;i<n;i++) dp[i][j]=(S[n+1]-S[i+1]+MOD)%MOD*modpow(n-i,MOD-2)%MOD;
}
cout<<dp[0][k]<<endl;
return 0;
}
umezo