結果
問題 |
No.2807 Have Another Go (Easy)
|
ユーザー |
|
提出日時 | 2024-07-12 21:33:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 3,000 ms |
コード長 | 622 bytes |
コンパイル時間 | 624 ms |
コンパイル使用メモリ | 72,576 KB |
実行使用メモリ | 7,568 KB |
最終ジャッジ日時 | 2024-07-12 21:33:53 |
合計ジャッジ時間 | 2,385 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
#include<iostream> #include<set> #include<vector> #include<cassert> #include<atcoder/modint> using namespace std; using mint=atcoder::modint998244353; mint dp[1<<20]; int N,M,K; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>M>>K; dp[0]=1; for(int i=0;i<N+N;i++) { for(int x=1;x<=6;x++)dp[i+x]+=dp[i]; } for(;K--;) { int C;cin>>C; mint c=0,nc=0; for(int x=1;x<=6;x++) { int l=N+N-C-x,r=N+N-C-1; l=max(l,0); for(int t=l;t<=r;t++)c+=dp[t]; l=N-C-x,r=N-C-1; l=max(l,0); for(int t=l;t<=r;t++)nc+=dp[t]; } cout<<(c*dp[C]+nc*(dp[N+C]-dp[C]*dp[N])).val()<<"\n"; } }