結果

問題 No.2709 1975 Powers
ユーザー Nikkuniku029Nikkuniku029
提出日時 2024-03-31 17:30:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 88,796 KB
最終ジャッジ日時 2024-03-31 17:30:38
合計ジャッジ時間 5,077 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,480 KB
testcase_01 AC 41 ms
55,480 KB
testcase_02 AC 58 ms
66,648 KB
testcase_03 AC 129 ms
68,720 KB
testcase_04 AC 194 ms
71,584 KB
testcase_05 AC 154 ms
74,148 KB
testcase_06 AC 109 ms
74,044 KB
testcase_07 AC 43 ms
55,480 KB
testcase_08 AC 130 ms
87,100 KB
testcase_09 AC 170 ms
77,308 KB
testcase_10 AC 44 ms
55,480 KB
testcase_11 AC 62 ms
67,036 KB
testcase_12 AC 77 ms
76,580 KB
testcase_13 AC 200 ms
87,220 KB
testcase_14 AC 79 ms
70,104 KB
testcase_15 AC 89 ms
74,176 KB
testcase_16 AC 147 ms
75,692 KB
testcase_17 AC 64 ms
68,736 KB
testcase_18 AC 88 ms
80,016 KB
testcase_19 AC 234 ms
88,796 KB
testcase_20 AC 71 ms
74,580 KB
testcase_21 AC 118 ms
83,484 KB
testcase_22 AC 179 ms
70,412 KB
testcase_23 AC 267 ms
83,884 KB
testcase_24 AC 222 ms
82,752 KB
testcase_25 AC 181 ms
70,104 KB
testcase_26 AC 195 ms
68,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P, Q = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
from collections import defaultdict
from bisect import bisect_right

five = defaultdict(list)
seven = defaultdict(int)
nine = defaultdict(int)
ten = defaultdict(int)
for a in A:
    seven[a] = pow(7, a, P)
    nine[a] = pow(9, a, P)
    ten[a] = pow(10, a, P)
    five[pow(5, a, P)].append(a)
ans = 0
for a in range(N):
    for b in range(a + 1, N):
        for c in range(b + 1, N):
            x = (ten[A[a]] + nine[A[b]] + seven[A[c]]) % P
            y = len(five[(Q - x) % P]) - bisect_right(five[(Q - x) % P], A[c])
            ans += y
print(ans)
0