結果

問題 No.2709 1975 Powers
ユーザー miya145592miya145592
提出日時 2024-03-31 14:14:03
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 655 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 208,752 KB
最終ジャッジ日時 2024-03-31 14:14:32
合計ジャッジ時間 28,354 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 175 ms
106,120 KB
testcase_03 AC 1,344 ms
136,484 KB
testcase_04 TLE -
testcase_05 AC 1,523 ms
161,644 KB
testcase_06 AC 626 ms
96,212 KB
testcase_07 AC 66 ms
72,048 KB
testcase_08 AC 738 ms
157,636 KB
testcase_09 AC 1,563 ms
171,444 KB
testcase_10 AC 68 ms
72,948 KB
testcase_11 AC 169 ms
84,108 KB
testcase_12 AC 388 ms
137,836 KB
testcase_13 AC 1,632 ms
195,296 KB
testcase_14 AC 408 ms
103,008 KB
testcase_15 AC 572 ms
151,564 KB
testcase_16 AC 1,254 ms
120,316 KB
testcase_17 AC 92 ms
79,448 KB
testcase_18 AC 432 ms
140,924 KB
testcase_19 TLE -
testcase_20 AC 164 ms
104,916 KB
testcase_21 AC 698 ms
154,836 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
権限があれば一括ダウンロードができます

ソースコード

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)
    for j in range(P):
        if j==q:
            dp[i+1][j] = dp[i][j]+1
        else:
            dp[i+1][j] = dp[i][j]
ans = 0
for i in range(N):
    a = A[i]
    for j in range(i+1, N):
        b = A[j]
        for k in range(j+1, N):
            c = A[k]
            tmp = pow(10, a, P)+pow(9, b, P)+pow(7, c, P)
            tmp %= P
            tmp = (Q-tmp)%P
            cnt = dp[N][tmp]-dp[k+1][tmp]
            ans += cnt
print(ans)
0