結果

問題 No.2530 Yellow Cards
ユーザー keisuke6keisuke6
提出日時 2023-11-03 22:29:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 713 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 205,636 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-11-03 22:30:04
合計ジャッジ時間 6,041 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 8 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 998244353;
long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
signed main(){
	int N,K;
	cin>>N>>K;
	vector<int> dp(N+1,0);
	dp[0] = 1;
	for(int i=0;i<K;i++){
		vector<int> ddp(N+1,0);
		for(int j=0;j<N;j++) ddp[j+1] = (ddp[j+1]+dp[j]*modinv(N)%mod*(N-j)%mod)%mod;
		for(int j=N;j>0;j--) ddp[j-1] = (ddp[j-1]+dp[j]*modinv(N)%mod*j%mod)%mod;
		dp = ddp;
	}
	int ans = 0;
	for(int i=0;i<=N;i++) ans = (ans+(N+(K-i)/2)*dp[i])%mod;
	cout<<ans<<endl;
}
0