結果
問題 | No.2530 Yellow Cards |
ユーザー | maksim |
提出日時 | 2023-11-03 22:01:43 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 219 ms / 2,000 ms |
コード長 | 816 bytes |
コンパイル時間 | 1,497 ms |
コンパイル使用メモリ | 167,884 KB |
実行使用メモリ | 4,348 KB |
最終ジャッジ日時 | 2023-11-03 22:02:09 |
合計ジャッジ時間 | 4,057 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 14 ms
4,348 KB |
testcase_03 | AC | 7 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 13 ms
4,348 KB |
testcase_06 | AC | 1 ms
4,348 KB |
testcase_07 | AC | 197 ms
4,348 KB |
testcase_08 | AC | 198 ms
4,348 KB |
testcase_09 | AC | 198 ms
4,348 KB |
testcase_10 | AC | 219 ms
4,348 KB |
testcase_11 | AC | 197 ms
4,348 KB |
testcase_12 | AC | 199 ms
4,348 KB |
testcase_13 | AC | 197 ms
4,348 KB |
testcase_14 | AC | 142 ms
4,348 KB |
testcase_15 | AC | 94 ms
4,348 KB |
testcase_16 | AC | 94 ms
4,348 KB |
testcase_17 | AC | 174 ms
4,348 KB |
testcase_18 | AC | 61 ms
4,348 KB |
testcase_19 | AC | 17 ms
4,348 KB |
testcase_20 | AC | 28 ms
4,348 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long const int p=998244353; int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*u)%p;} else {int u=po(a,b-1);return (a*u)%p;}} int inv(int x) {return po(x,p-2);} const int maxn=5e3+5; int ways[maxn];int ways2[maxn]; int res; int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n,k;cin>>n>>k;ways[0]=1;int in=inv(n);res=n; for(int i=0;i<k;++i) { fill(ways2,ways2+maxn,0); for(int j=0;j<=n;++j) { ways2[j+1]+=(((n-j)*in)%p)*ways[j];ways2[j+1]%=p; if(j) {int h=(((j*in)%p)*ways[j])%p;ways2[j-1]+=h;ways2[j-1]%=p;res+=h;res%=p;} } copy(ways2,ways2+maxn,ways); } cout<<(res%p+p)%p; return 0; }