結果

問題 No.2709 1975 Powers
ユーザー noriocnorioc
提出日時 2024-04-01 01:48:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 801 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 144,440 KB
最終ジャッジ日時 2024-04-01 01:48:57
合計ジャッジ時間 23,093 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 111 ms
138,028 KB
testcase_03 AC 1,747 ms
138,268 KB
testcase_04 TLE -
testcase_05 AC 1,903 ms
138,060 KB
testcase_06 AC 659 ms
138,820 KB
testcase_07 AC 66 ms
121,116 KB
testcase_08 AC 621 ms
139,248 KB
testcase_09 AC 1,965 ms
137,600 KB
testcase_10 AC 67 ms
122,348 KB
testcase_11 AC 145 ms
141,708 KB
testcase_12 AC 224 ms
138,140 KB
testcase_13 AC 1,970 ms
137,952 KB
testcase_14 AC 343 ms
136,776 KB
testcase_15 AC 385 ms
137,124 KB
testcase_16 AC 1,555 ms
139,060 KB
testcase_17 AC 83 ms
133,240 KB
testcase_18 AC 262 ms
137,792 KB
testcase_19 TLE -
testcase_20 AC 110 ms
140,256 KB
testcase_21 AC 583 ms
136,964 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations

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


m = max(A) + 10
memo10 = [-1] * m
memo9 = [-1] * m
memo7 = [-1] * m
memo5 = [-1] * m


def f10(x):
    if memo10[x] != -1: return memo10[x]
    res = pow(10, x, P)
    memo10[x] = res
    return res


def f9(x):
    if memo9[x] != -1: return memo9[x]
    res = pow(9, x, P)
    memo9[x] = res
    return res


def f7(x):
    if memo7[x] != -1: return memo7[x]
    res = pow(7, x, P)
    memo7[x] = res
    return res


def f5(x):
    if memo5[x] != -1: return memo5[x]
    res = pow(5, x, P)
    memo5[x] = res
    return res


ans = 0
for a, b, c, d in combinations(A, 4):
    x = f10(a)
    x += f9(b)
    x += f7(c)
    x += f5(d)
    if x % P == Q:
        ans += 1

print(ans)
0