結果

問題 No.2709 1975 Powers
ユーザー RYOH2718RYOH2718
提出日時 2024-03-31 14:55:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,122 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 80,620 KB
最終ジャッジ日時 2024-03-31 14:56:18
合計ジャッジ時間 26,106 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 110 ms
71,964 KB
testcase_03 AC 1,260 ms
73,476 KB
testcase_04 AC 1,910 ms
73,872 KB
testcase_05 AC 1,481 ms
79,248 KB
testcase_06 AC 604 ms
74,664 KB
testcase_07 AC 56 ms
67,688 KB
testcase_08 AC 638 ms
80,184 KB
testcase_09 AC 1,441 ms
74,632 KB
testcase_10 AC 57 ms
67,720 KB
testcase_11 AC 152 ms
73,756 KB
testcase_12 AC 270 ms
80,620 KB
testcase_13 AC 1,508 ms
80,520 KB
testcase_14 AC 357 ms
69,196 KB
testcase_15 AC 422 ms
76,096 KB
testcase_16 AC 1,206 ms
77,928 KB
testcase_17 AC 76 ms
71,944 KB
testcase_18 AC 327 ms
75,228 KB
testcase_19 AC 1,881 ms
79,296 KB
testcase_20 AC 104 ms
74,640 KB
testcase_21 AC 593 ms
71,948 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 標準入力された値を整数に変換する
def INT():
    return int(input())


# 標準入力された複数の値を整数に変換する
def MI():
    return map(int, input().split())


# 標準入力された複数の値を整数のリストに変換する
def LI():
    return list(map(int, input().split()))


from bisect import bisect_right

N, P, Q = MI()
A = LI()

mod5s = [0] * P
cnt5s = [[] for _ in range(P)]
for i in range(N):
    mod5s[pow(5, A[i], P)] += 1
    cnt5s[pow(5, A[i], P)].append(A[i])

for i in range(P):
    cnt5s[i].sort()

ans = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if not (A[i] < A[j] and A[j] < A[k]):
                continue
            p10 = pow(10, A[i], P)
            p9 = pow(9, A[j], P)
            p7 = pow(7, A[k], P)

            three_mod = (p10 + p9 + p7) % P
            res = (Q - three_mod + P) % P
            # if len(cnt5s[res]) - bisect_right(cnt5s[res], A[k]):
            #     print(A[k], cnt5s[res], bisect_right(cnt5s[res], A[k]))
            ans += len(cnt5s[res]) - bisect_right(cnt5s[res], A[k])

print(ans)
0