結果

問題 No.2530 Yellow Cards
ユーザー cho435cho435
提出日時 2023-11-03 23:11:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,603 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 3,815 ms
コンパイル使用メモリ 264,952 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-11-03 23:12:11
合計ジャッジ時間 20,843 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 4 ms
4,372 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 1,603 ms
4,372 KB
testcase_08 AC 1,579 ms
4,372 KB
testcase_09 AC 1,594 ms
4,372 KB
testcase_10 AC 1,601 ms
4,372 KB
testcase_11 AC 1,578 ms
4,372 KB
testcase_12 AC 1,580 ms
4,372 KB
testcase_13 AC 1,600 ms
4,372 KB
testcase_14 AC 1,373 ms
4,372 KB
testcase_15 AC 994 ms
4,372 KB
testcase_16 AC 783 ms
4,372 KB
testcase_17 AC 1,416 ms
4,372 KB
testcase_18 AC 295 ms
4,372 KB
testcase_19 AC 54 ms
4,372 KB
testcase_20 AC 283 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

int main(){
	int n,k;
	cin>>n>>k;
	vector<mint> dp(n+1,0);
	dp.at(0)=1;
	rep(i,k){
		vector<mint> ndp(n+1,0);
		rep(j,n+1){
			if(dp.at(j)==0) continue;
			if(j<n) ndp.at(j+1)+=(dp.at(j))*(n-j)/n;
			if(j>0) ndp.at(j-1)+=(dp.at(j))*(j)/n;
		}
		swap(dp,ndp);
	}
	mint ans=0;
	rep(i,n+1) ans+=dp.at(i)*(n+(k-i)/2);
	cout<<ans.val()<<endl;
}
0