結果

問題 No.1967 Sugoroku Optimization
ユーザー HaaHaa
提出日時 2022-06-03 22:41:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 591 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 172,052 KB
実行使用メモリ 34,748 KB
最終ジャッジ日時 2023-10-21 02:09:29
合計ジャッジ時間 7,316 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 590 ms
34,748 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 529 ms
31,316 KB
testcase_06 AC 565 ms
33,428 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 398 ms
24,452 KB
testcase_09 AC 299 ms
18,908 KB
testcase_10 AC 142 ms
10,724 KB
testcase_11 AC 19 ms
4,388 KB
testcase_12 AC 362 ms
22,604 KB
testcase_13 AC 180 ms
12,836 KB
testcase_14 AC 11 ms
4,348 KB
testcase_15 AC 12 ms
4,348 KB
testcase_16 AC 19 ms
4,348 KB
testcase_17 AC 23 ms
4,388 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 591 ms
34,748 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 590 ms
34,748 KB
testcase_23 AC 360 ms
22,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

ll power(ll x, ll y){
    x%=MOD;
    ll ret=1;
    while(y){
        if(y&1) ret=ret*x%MOD;
        x=x*x%MOD;
        y>>=1;
    }
    return ret;
}

ll divid(ll x, ll y){
    x%=MOD;
    return x*power(y,MOD-2)%MOD;
}

int main(){
    int n, k; cin >> n >> k;
    VVI dp(k+1,VI(n+1,0));
    dp[0][0]=1;
    ll ans=0;
    REP(i,k){
        ll sum=0;
        REP(j,n+1){
            dp[i+1][j]=sum;
            sum=(sum+divid(dp[i][j],n-j))%MOD;
        }
        ans=(ans+dp[i+1][n])%MOD;
    }
    cout << ans << endl;
    return 0;
}
0