結果

問題 No.2807 Have Another Go (Easy)
ユーザー zeta7532zeta7532
提出日時 2024-07-09 21:44:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 3,000 ms
コード長 1,163 bytes
コンパイル時間 2,412 ms
コンパイル使用メモリ 206,192 KB
実行使用メモリ 11,348 KB
最終ジャッジ日時 2024-07-09 21:44:11
合計ジャッジ時間 5,437 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 35 ms
10,748 KB
testcase_02 AC 29 ms
7,912 KB
testcase_03 AC 24 ms
7,040 KB
testcase_04 AC 16 ms
6,656 KB
testcase_05 AC 33 ms
9,084 KB
testcase_06 AC 31 ms
8,832 KB
testcase_07 AC 9 ms
5,376 KB
testcase_08 AC 13 ms
5,376 KB
testcase_09 AC 17 ms
5,632 KB
testcase_10 AC 18 ms
7,168 KB
testcase_11 AC 42 ms
11,136 KB
testcase_12 AC 41 ms
11,124 KB
testcase_13 AC 42 ms
11,076 KB
testcase_14 AC 42 ms
11,008 KB
testcase_15 AC 41 ms
11,348 KB
testcase_16 AC 41 ms
10,880 KB
testcase_17 AC 42 ms
11,008 KB
testcase_18 AC 41 ms
11,072 KB
testcase_19 AC 40 ms
11,008 KB
testcase_20 AC 42 ms
10,880 KB
testcase_21 AC 42 ms
11,008 KB
testcase_22 AC 43 ms
11,008 KB
testcase_23 AC 42 ms
11,008 KB
testcase_24 AC 40 ms
11,136 KB
testcase_25 AC 43 ms
10,880 KB
testcase_26 AC 42 ms
11,008 KB
testcase_27 AC 41 ms
11,136 KB
testcase_28 AC 42 ms
10,880 KB
testcase_29 AC 41 ms
10,880 KB
testcase_30 AC 41 ms
11,136 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 9 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 8 ms
5,376 KB
testcase_41 AC 9 ms
5,376 KB
testcase_42 AC 9 ms
5,376 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 7 ms
5,376 KB
testcase_45 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)

int main() {
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> C(K);
    rep(i,K) cin >> C[i];
    vector<ll> dp(N*M,0);
    dp[0]=1;
    for(ll i=1;i<N*M;i++){
        for(ll j=1;j<=6;j++){
            if(i<j) continue;
            dp[i]+=dp[i-j];
            dp[i]%=mod;
        }
    }
    rep(i,K){
        ll ANS=0;
        rep(j,6){
            ANS+=dp[C[i]]*((dp[N*M-j-1-C[i]]*(6-j))%mod);
            ANS%=mod;
        }
        rep(j,6){
            if(N*M-j-1-C[i]-N<0) continue;
            ANS+=dp[C[i]+N]*((dp[N*M-j-1-C[i]-N]*(6-j))%mod);
            ANS%=mod;
        }
        rep(j,6){
            if(N*M-j-1-C[i]-N<0) continue;
            ANS+=mod*mod-((dp[C[i]]*dp[N])%mod)*((dp[N*M-j-1-C[i]-N]*(6-j))%mod);
            ANS%=mod;
        }
        cout << ANS << endl;
    }
    return 0;
}
0