結果

問題 No.2709 1975 Powers
ユーザー miya145592miya145592
提出日時 2024-03-31 14:17:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,070 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 261,364 KB
最終ジャッジ日時 2024-03-31 14:17:47
合計ジャッジ時間 14,941 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 136 ms
145,084 KB
testcase_03 AC 630 ms
204,032 KB
testcase_04 AC 1,047 ms
244,224 KB
testcase_05 AC 742 ms
245,044 KB
testcase_06 AC 319 ms
123,644 KB
testcase_07 AC 62 ms
83,408 KB
testcase_08 AC 420 ms
241,828 KB
testcase_09 AC 819 ms
244,336 KB
testcase_10 AC 63 ms
85,196 KB
testcase_11 AC 115 ms
101,492 KB
testcase_12 AC 246 ms
204,240 KB
testcase_13 AC 879 ms
245,020 KB
testcase_14 AC 231 ms
139,204 KB
testcase_15 AC 354 ms
233,824 KB
testcase_16 AC 589 ms
171,748 KB
testcase_17 AC 79 ms
92,012 KB
testcase_18 AC 273 ms
210,428 KB
testcase_19 AC 993 ms
245,248 KB
testcase_20 AC 132 ms
140,556 KB
testcase_21 AC 441 ms
240,420 KB
testcase_22 AC 1,048 ms
261,364 KB
testcase_23 AC 1,052 ms
245,232 KB
testcase_24 AC 966 ms
194,580 KB
testcase_25 AC 1,048 ms
243,944 KB
testcase_26 AC 1,070 ms
245,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, P, Q = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
dp = [[0 for _ in range(P)] for _ in range(N+1)]
for i in range(N):
    q = pow(5, A[i], P)
    dp[i+1] = dp[i][:]
    dp[i+1][q]+=1
ans = 0
for i in range(N):
    a = A[i]
    tmpa = pow(10, a, P)
    for j in range(i+1, N):
        b = A[j]
        tmpb = pow(9, b, P)
        for k in range(j+1, N):
            c = A[k]
            tmp = (tmpa+tmpb)%P+pow(7, c, P)
            tmp %= P
            tmp = (Q-tmp)%P
            cnt = dp[N][tmp]-dp[k+1][tmp]
            ans += cnt
print(ans)
0