結果
問題 | No.2807 Have Another Go (Easy) |
ユーザー |
|
提出日時 | 2024-07-12 22:25:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 3,000 ms |
コード長 | 1,449 bytes |
コンパイル時間 | 2,170 ms |
コンパイル使用メモリ | 200,160 KB |
最終ジャッジ日時 | 2025-02-22 04:25:46 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/modint> using namespace std; using ll=long long; using mint=atcoder::modint998244353; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M,K; cin>>N>>M>>K; vector<int>C(K); for(int i=0;i<K;i++)cin>>C[i]; vector<mint>dp(2*N+6); dp[0]=1; for(int i=1;i<=2*N+5;i++){ for(int j=1;j<=6;j++){ if(0<=i-j&&i-j<2*N)dp[i]+=dp[i-j]; } } vector<mint>pd(N+6); for(int i=0;i<6;i++)pd[N+i]=1; for(int i=N-1;i>=0;i--){ for(int j=1;j<=6;j++)pd[i]+=pd[i+j]; } mint al=0; for(int i=0;i<6;i++)al+=dp[2*N+i]; for(int i=0;i<K;i++){ int c=C[i]; mint ans=0; for(int j=1;j<=5;j++){ for(int k=j+1;k<=6;k++){ if(c-j>=0){ for(int l=1;l<=5;l++){ for(int m=l+1;m<=6;m++){ if(c-j+k<=N+c-l){ ans+=dp[c-j]*dp[(N+c-l)-(c-j+k)]*pd[c-l+m]; } } } } } } ans=al-ans; cout<<ans.val()<<"\n"; } }