結果

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

ソースコード

diff #

from itertools import combinations


def main():
    N, P, Q = map(int, input().split())
    A = sorted(map(int, input().split()))
    A_10 = [pow(10, a_elm, P) for a_elm in A]
    A_9 = [pow(9, a_elm, P) for a_elm in A]
    A_7 = [pow(7, a_elm, P) for a_elm in A]
    A_5 = [pow(5, a_elm, P) for a_elm in A]
    # divisors = [10, 9, 7, 5]
    # A_mod = [[pow(div_, a_elm, P) for div_ in divisors] for a_elm in A]
    ctr = 0
    for idx1, idx2, idx3, idx4 in combinations(range(N), r=4):
        if (A_10[idx1] + A_9[idx2] +
                A_7[idx3] + A_5[idx4]) % P == Q:
            ctr += 1
    print(ctr)


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