結果
問題 |
No.2709 1975 Powers
|
ユーザー |
|
提出日時 | 2024-04-10 15:36:08 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 743 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 82,708 KB |
実行使用メモリ | 88,548 KB |
最終ジャッジ日時 | 2024-10-02 17:26:43 |
合計ジャッジ時間 | 26,457 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 TLE * 5 |
ソースコード
from bisect import bisect_left, bisect_right 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(list) for a_elm in A: mod_P_pow_5[pow(5, a_elm, P)].append(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(mod_P_pow_5[rest_mod]) - \ bisect_right(mod_P_pow_5[rest_mod], c) print(ctr) if __name__ == "__main__": main()