結果
| 問題 | No.2709 1975 Powers | 
| コンテスト | |
| ユーザー |  norioc | 
| 提出日時 | 2024-04-01 01:36:30 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 408 bytes | 
| コンパイル時間 | 371 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 82,048 KB | 
| 最終ジャッジ日時 | 2024-09-30 21:34:51 | 
| 合計ジャッジ時間 | 4,000 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 1 TLE * 1 -- * 23 | 
ソースコード
from itertools import combinations
N, P, Q = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
memo = {}
def f(a, b):
    if (a, b) in memo: return memo[a, b]
    res = pow(a, b, P)
    memo[a, b] = res
    return res
ans = 0
for a, b, c, d in combinations(A, 4):
    x = f(10, a)
    x += f(9, b)
    x += f(7, c)
    x += f(5, d)
    if x % P == Q:
        ans += 1
print(ans)
            
            
            
        