結果
問題 |
No.2807 Have Another Go (Easy)
|
ユーザー |
|
提出日時 | 2024-07-13 02:29:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 3,000 ms |
コード長 | 997 bytes |
コンパイル時間 | 4,274 ms |
コンパイル使用メモリ | 254,136 KB |
最終ジャッジ日時 | 2025-02-22 06:13:41 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) template<typename T> bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } template<typename T> bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; } struct io_setup { io_setup() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; using mint = atcoder::modint998244353; int main(){ ll n,m,k; cin>>n>>m>>k; vector<ll> c(k); rep(i,0,k) cin>>c.at(i); vector<mint> dp(n*m+1,0); dp.at(0)=1; rep(i,0,n*m){ for(int j=1;j<=6;j++){ dp.at(min(i+j,n*m))+=dp.at(i); } } rep(i,0,k){ mint ans=0; rep(j,0,6){ if(n*2-c.at(i)-1-j>=0) ans+=dp.at(c.at(i))*dp.at(n*2-c.at(i)-1-j)*(6-j); if(n-c.at(i)-1-j>=0){ ans+=dp.at(c.at(i)+n)*dp.at(n-c.at(i)-1-j)*(6-j); ans-=dp.at(c.at(i))*dp.at(n)*dp.at(n-c.at(i)-1-j)*(6-j); } } cout<<ans.val()<<"\n"; } }