結果

問題 No.1967 Sugoroku Optimization
ユーザー umezoumezo
提出日時 2022-06-05 21:36:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 634 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 1,959 ms
コンパイル使用メモリ 203,804 KB
実行使用メモリ 35,184 KB
最終ジャッジ日時 2023-10-21 03:18:18
合計ジャッジ時間 8,423 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 632 ms
35,184 KB
testcase_04 AC 11 ms
11,608 KB
testcase_05 AC 574 ms
35,168 KB
testcase_06 AC 610 ms
35,044 KB
testcase_07 AC 11 ms
13,092 KB
testcase_08 AC 438 ms
32,188 KB
testcase_09 AC 329 ms
27,236 KB
testcase_10 AC 150 ms
16,656 KB
testcase_11 AC 27 ms
12,956 KB
testcase_12 AC 398 ms
30,620 KB
testcase_13 AC 200 ms
22,220 KB
testcase_14 AC 20 ms
12,044 KB
testcase_15 AC 18 ms
10,980 KB
testcase_16 AC 23 ms
10,780 KB
testcase_17 AC 28 ms
10,488 KB
testcase_18 AC 7 ms
9,448 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 630 ms
35,168 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 634 ms
35,184 KB
testcase_23 AC 390 ms
30,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0