結果

問題 No.2807 Have Another Go (Easy)
ユーザー titia
提出日時 2024-07-16 04:09:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 3,000 ms
コード長 627 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 84,504 KB
最終ジャッジ日時 2024-07-16 04:09:29
合計ジャッジ時間 6,953 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M,k=map(int,input().split())

mod=998244353

DP=[0]*(N*M+8)
DP[0]=1

for i in range(N*M):
    for j in range(1,7):
        DP[i+j]=(DP[i+j]+DP[i])%mod

C=list(map(int,input().split()))

for c in C:
    # cを通る
    ANS=0
    for i in range(1,7):
        ANS+=DP[c]*DP[N*M-i-c]*(6-i+1)

    #print(ANS)

    # c+Nを通る
    for i in range(1,7):
        if c+N<=N*M-i:
            ANS+=DP[c+N]*DP[N*M-i-(c+N)]*(6-i+1)

    #print(ANS)

    # cとc+Nを通る
    for i in range(1,7):
        if c+N<=N*M-i:
            ANS-=DP[c]*DP[N]*DP[N*M-i-(c+N)]*(6-i+1)

    print(ANS%mod)

0