結果

問題 No.2709 1975 Powers
ユーザー Theta
提出日時 2025-05-26 18:15:30
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 862 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 674,380 KB
最終ジャッジ日時 2025-05-26 18:15:35
合計ジャッジ時間 4,444 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other MLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, P, Q = map(int, input().split())
    A = sorted(map(int, input().split()))
    divisors = [10, 9, 7, 5]
    A_mod = [{div_: pow(div_, a_elm, P) for div_ in divisors} for a_elm in A]

    table = [[[0 for _ in range(5)] for _ in range(P)] for _ in range(N + 1)]
    table[0][0][0] = 1

    for idx, mod_elm in enumerate(A_mod):
        for cur_rest in range(P):
            for cur_phase in range(5):
                if table[idx][cur_rest][cur_phase] == 0:
                    continue
                table[idx + 1][cur_rest][cur_phase] += table[idx][cur_rest][cur_phase]
                if cur_phase < 4:

                    table[idx + 1][(cur_rest + mod_elm[divisors[cur_phase]]) %
                                   P][cur_phase + 1] += table[idx][cur_rest][cur_phase]
    print(table[-1][Q][-1])


if __name__ == "__main__":
    main()
0