結果
| 問題 | No.2709 1975 Powers |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-10 15:34:00 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,111 ms / 2,000 ms |
| コード長 | 674 bytes |
| 記録 | |
| コンパイル時間 | 302 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 93,580 KB |
| 最終ジャッジ日時 | 2026-04-19 01:31:53 |
| 合計ジャッジ時間 | 15,092 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
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()