結果

問題 No.2709 1975 Powers
ユーザー pitPpitP
提出日時 2024-03-31 13:56:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 85,116 KB
最終ジャッジ日時 2024-03-31 13:56:21
合計ジャッジ時間 3,569 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,616 KB
testcase_01 AC 41 ms
55,616 KB
testcase_02 AC 63 ms
68,528 KB
testcase_03 AC 89 ms
69,384 KB
testcase_04 AC 98 ms
76,588 KB
testcase_05 AC 102 ms
74,520 KB
testcase_06 AC 77 ms
71,908 KB
testcase_07 AC 41 ms
55,612 KB
testcase_08 AC 93 ms
83,500 KB
testcase_09 AC 108 ms
75,144 KB
testcase_10 AC 43 ms
55,616 KB
testcase_11 AC 67 ms
70,668 KB
testcase_12 AC 74 ms
76,536 KB
testcase_13 AC 123 ms
85,116 KB
testcase_14 AC 65 ms
69,992 KB
testcase_15 AC 77 ms
74,580 KB
testcase_16 AC 79 ms
70,544 KB
testcase_17 AC 53 ms
64,424 KB
testcase_18 AC 76 ms
79,996 KB
testcase_19 AC 130 ms
80,812 KB
testcase_20 AC 65 ms
70,236 KB
testcase_21 AC 93 ms
83,464 KB
testcase_22 AC 123 ms
74,884 KB
testcase_23 AC 111 ms
80,812 KB
testcase_24 AC 120 ms
75,944 KB
testcase_25 AC 95 ms
72,520 KB
testcase_26 AC 118 ms
71,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

base = [10, 9, 7, 5]
g = [[pow(base[c], A[i], P) for i in range(N)] for c in range(4)]

mp = defaultdict(int)
mp[g[0][0]] = 1
ans = 0
for b in range(1, N):
    for c in range(b + 1, N):
        for d in range(c + 1, N):
            Y = (g[1][b] + g[2][c] + g[3][d]) % P
            ans += mp[(Q - Y) % P]
    mp[g[0][b]] += 1

print(ans)
0