結果

問題 No.2709 1975 Powers
ユーザー NP
提出日時 2024-03-31 15:12:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 429 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 75,648 KB
最終ジャッジ日時 2024-09-30 20:23:15
合計ジャッジ時間 5,883 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 12 TLE * 4 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations

def count_ways(N, P, Q, A):
    powers = [[pow(x, A[i], P) for x in [10, 9, 7, 5]] for i in range(N)]
    
    ways = 0
    for a, b, c, d in combinations(range(N), 4):
        if (powers[a][0] + powers[b][1] + powers[c][2] + powers[d][3]) % P == Q:
            ways += 1
    return ways

N, P, Q = map(int, input().split())
A = list(map(int, input().split()))

print(count_ways(N, P, Q, A))

0