結果

問題 No.2709 1975 Powers
ユーザー navel_tosnavel_tos
提出日時 2024-03-31 16:33:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 853 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 62,376 KB
最終ジャッジ日時 2024-03-31 16:33:07
合計ジャッジ時間 2,724 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 42 ms
53,460 KB
testcase_02 AC 49 ms
60,104 KB
testcase_03 AC 63 ms
62,216 KB
testcase_04 AC 71 ms
62,216 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 38 ms
53,460 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 41 ms
53,460 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 54 ms
60,092 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 69 ms
62,216 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 68 ms
62,216 KB
testcase_26 AC 76 ms
62,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#MMA Contest 018 D

N, P, Q = map(int, input().split())
A = list(map(int, input().split()))

#事前に冪を求めておく
#Aw + Ax + Ay + Az の順に対応させたいので、後はよしなに
W = [pow(10, a, P) for a in A]
X = [pow( 9, b, P) for b in A]
Y = [pow( 7, c, P) for c in A]
Z = [pow( 5, d, P) for d in A]

#Zを連想配列に変換  c < dとなるdであって、5^d = Zi となる個数
D = dict()
for Zi in Z:
    if Zi not in D:
        D[Zi] = 0
    D[Zi] += 1

ans = 0
for c in range(N):
    y = Y[c]
    D[ Z[c] ] -= 1
    for b in range(c):
        x = X[b]
        for a in range(b):
            assert a < b < c
            w = W[a]

            #w + x + y + z ≡ Q mod P
            #z = Q - (w + x + y) mod P
            z = Q - (w + x + y)
            z %= P
            if z in D:
                ans += D[z]
print(ans)
0