結果
問題 | No.2807 Have Another Go (Easy) |
ユーザー |
|
提出日時 | 2024-07-12 21:59:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 3,000 ms |
コード長 | 636 bytes |
コンパイル時間 | 1,732 ms |
コンパイル使用メモリ | 171,768 KB |
実行使用メモリ | 11,112 KB |
最終ジャッジ日時 | 2024-07-12 21:59:16 |
合計ジャッジ時間 | 3,882 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
#include<bits/stdc++.h>using namespace std;#define int long longvector<int> dp;int f(int n) {int ans = 0;for(int i = n-6; i < n; i++) {if(i >= 0) ans+=dp[i]*(7-n+i);ans%=998244353;}return ans;}signed main() {int n,t,m;cin >> n >> t >> m;int mod = 998244353;dp.resize(n*2+7);dp[0] = 1;for(int i = 0; i < n*2+6; i++) {for(int j = 1; j <= 6; j++) {if(i+j > n*2+6) break;dp[i+j]+=dp[i];dp[i+j]%=mod;}}while(m--) {int i;cin >> i;int ans = 0;ans-=dp[i]*dp[n]%mod*f(n-i)%mod;ans+=dp[i]*f(n*2-i)%mod;ans+=dp[n+i]*f(n-i)%mod;ans+=mod*mod;cout << ans%mod << endl;}}