結果

問題 No.2709 1975 Powers
ユーザー 👑 KA37RIKA37RI
提出日時 2024-03-31 14:24:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,840 KB
最終ジャッジ日時 2024-03-31 14:24:57
合計ジャッジ時間 3,492 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,608 KB
testcase_01 AC 40 ms
55,608 KB
testcase_02 AC 50 ms
64,320 KB
testcase_03 AC 104 ms
75,840 KB
testcase_04 AC 134 ms
75,840 KB
testcase_05 AC 114 ms
75,840 KB
testcase_06 AC 80 ms
75,840 KB
testcase_07 AC 41 ms
55,608 KB
testcase_08 AC 78 ms
75,712 KB
testcase_09 AC 113 ms
75,840 KB
testcase_10 AC 44 ms
55,608 KB
testcase_11 AC 53 ms
66,368 KB
testcase_12 AC 58 ms
68,416 KB
testcase_13 AC 115 ms
75,840 KB
testcase_14 AC 63 ms
72,512 KB
testcase_15 AC 66 ms
73,152 KB
testcase_16 AC 105 ms
75,840 KB
testcase_17 AC 45 ms
62,100 KB
testcase_18 AC 60 ms
70,464 KB
testcase_19 AC 131 ms
75,840 KB
testcase_20 AC 49 ms
64,320 KB
testcase_21 AC 76 ms
75,712 KB
testcase_22 AC 135 ms
75,840 KB
testcase_23 AC 141 ms
75,840 KB
testcase_24 AC 142 ms
75,840 KB
testcase_25 AC 135 ms
75,840 KB
testcase_26 AC 138 ms
75,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

def solve(n, p, q, a):
  b = sorted(a)
  pow10 = [pow(10, x, p) for x in b]
  pow9 = [pow(9, x, p) for x in b]
  pow7 = [pow(7, x, p) for x in b]
  pow5 = [pow(5, x, p) for x in b]
  cnt = Counter()
  ans = 0
  for i in range(n):
    for j in range(i + 1, n):
      for k in range(j + 1, n):
        x = pow9[i] + pow7[j] + pow5[k]
        ans += cnt[(q - x) % p]
    cnt[pow10[i]] += 1
  return ans

n, p, q = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

print(solve(n, p, q, a))
0