結果

問題 No.2709 1975 Powers
ユーザー loop0919loop0919
提出日時 2024-03-31 13:59:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,161 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 249,564 KB
最終ジャッジ日時 2024-03-31 13:59:36
合計ジャッジ時間 19,043 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,604 KB
testcase_01 AC 41 ms
55,604 KB
testcase_02 AC 445 ms
246,648 KB
testcase_03 AC 816 ms
247,372 KB
testcase_04 AC 1,077 ms
245,608 KB
testcase_05 AC 819 ms
248,064 KB
testcase_06 AC 585 ms
248,340 KB
testcase_07 AC 273 ms
234,744 KB
testcase_08 AC 551 ms
249,564 KB
testcase_09 AC 902 ms
246,952 KB
testcase_10 AC 273 ms
238,132 KB
testcase_11 AC 430 ms
247,212 KB
testcase_12 AC 435 ms
248,252 KB
testcase_13 AC 859 ms
247,956 KB
testcase_14 AC 476 ms
245,536 KB
testcase_15 AC 551 ms
245,428 KB
testcase_16 AC 758 ms
249,092 KB
testcase_17 AC 426 ms
248,288 KB
testcase_18 AC 475 ms
247,420 KB
testcase_19 AC 1,031 ms
248,168 KB
testcase_20 AC 414 ms
245,752 KB
testcase_21 AC 543 ms
244,872 KB
testcase_22 AC 1,139 ms
247,964 KB
testcase_23 AC 1,140 ms
248,248 KB
testcase_24 AC 1,161 ms
248,224 KB
testcase_25 AC 1,109 ms
247,964 KB
testcase_26 AC 1,132 ms
247,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

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

li = [[None]*(A[-1]+1) for _ in range(11)]
def power(x, y):
    if li[x][y] == None: li[x][y] = pow(x, y, P)
    return li[x][y]

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]
            for l in range(k+1, N):
                d = A[l]
                if (power(10, a) + power(9, b) + power(7, c) + power(5, d)) % P == Q:
                    ans += 1

print(ans)
0