結果

問題 No.1967 Sugoroku Optimization
ユーザー asaringoasaringo
提出日時 2022-06-03 23:09:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 565 ms / 2,000 ms
コード長 1,275 bytes
コンパイル時間 1,914 ms
コンパイル使用メモリ 202,364 KB
実行使用メモリ 35,204 KB
最終ジャッジ日時 2023-10-21 02:20:26
合計ジャッジ時間 7,167 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 564 ms
35,188 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 494 ms
32,968 KB
testcase_06 AC 541 ms
35,016 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 370 ms
26,824 KB
testcase_09 AC 275 ms
20,680 KB
testcase_10 AC 138 ms
16,488 KB
testcase_11 AC 19 ms
6,344 KB
testcase_12 AC 343 ms
24,776 KB
testcase_13 AC 174 ms
14,536 KB
testcase_14 AC 12 ms
4,348 KB
testcase_15 AC 12 ms
6,272 KB
testcase_16 AC 18 ms
6,232 KB
testcase_17 AC 21 ms
6,176 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 565 ms
35,172 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 558 ms
35,204 KB
testcase_23 AC 353 ms
24,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
#define fast_input_output ios::sync_with_stdio(false); cin.tie(nullptr);
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

const int mod = 998244353 ;
ll powmod(ll x , ll n){
    ll res = 1 ;
    while(n > 0){
        if(n & 1) (res *= x) %= mod ;
        (x *= x) %= mod ;
        n >>= 1 ;
    }
    return res ;
}

int n , k ;
ll dp[2020][2020] ;

int main(){
    fast_input_output
    cin >> n >> k ;
    dp[0][0] = 1 ;
    rep(i,k){
        rep(j,n+1) {
            ll rem = n - j ;
            ll val = powmod(rem,mod-2) ;
            dp[i+1][j+1] += dp[i][j] * val % mod ;
            dp[i+1][n+1] -= dp[i][j] * val % mod ;
            dp[i+1][j+1] %= mod ;
            dp[i+1][n+1] += mod ;
            dp[i+1][n+1] %= mod ;
        }
        rep(j,n+2) (dp[i+1][j+1] += dp[i+1][j]) %= mod ;
    }
    ll res = 0 ;
    rep(i,k+1) (res += dp[i][n]) %= mod ;
    cout << res << endl ;
}
0