結果
問題 | No.2709 1975 Powers |
ユーザー | Theta |
提出日時 | 2024-04-10 15:34:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 674 bytes |
コンパイル時間 | 779 ms |
コンパイル使用メモリ | 82,440 KB |
実行使用メモリ | 88,384 KB |
最終ジャッジ日時 | 2024-10-02 17:24:16 |
合計ジャッジ時間 | 25,838 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 TLE * 2 |
ソースコード
from collections import defaultdict from itertools import combinations import sys def printe(*args, end="\n", **kwargs): print(*args, end=end, file=sys.stderr, **kwargs) def main(): N, P, Q = map(int, input().split()) A = list(map(int, input().split())) A.sort() mod_P_pow_5 = defaultdict(set) for a_elm in A: mod_P_pow_5[pow(5, a_elm, P)].add(a_elm) ctr = 0 for a, b, c in combinations(A, 3): c_mod = (pow(10, a, P) + pow(9, b, P) + pow(7, c, P)) % P rest_mod = (Q - c_mod) % P ctr += len(list(filter(lambda elm: elm > c, mod_P_pow_5[rest_mod]))) print(ctr) if __name__ == "__main__": main()