結果

問題 No.2709 1975 Powers
ユーザー playerplayer
提出日時 2024-04-04 13:59:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 824 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 138,612 KB
最終ジャッジ日時 2024-04-04 13:59:59
合計ジャッジ時間 10,783 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
124,092 KB
testcase_01 AC 86 ms
124,092 KB
testcase_02 AC 115 ms
130,896 KB
testcase_03 AC 412 ms
138,192 KB
testcase_04 AC 558 ms
138,192 KB
testcase_05 AC 540 ms
138,232 KB
testcase_06 AC 217 ms
138,224 KB
testcase_07 AC 101 ms
126,708 KB
testcase_08 AC 229 ms
138,228 KB
testcase_09 AC 426 ms
138,224 KB
testcase_10 AC 102 ms
126,728 KB
testcase_11 AC 125 ms
132,976 KB
testcase_12 AC 147 ms
136,560 KB
testcase_13 AC 534 ms
138,232 KB
testcase_14 AC 169 ms
138,192 KB
testcase_15 AC 182 ms
138,612 KB
testcase_16 AC 389 ms
138,224 KB
testcase_17 AC 112 ms
130,900 KB
testcase_18 AC 150 ms
136,176 KB
testcase_19 AC 710 ms
138,232 KB
testcase_20 AC 119 ms
133,512 KB
testcase_21 AC 226 ms
138,608 KB
testcase_22 AC 640 ms
138,192 KB
testcase_23 AC 692 ms
138,352 KB
testcase_24 AC 824 ms
138,232 KB
testcase_25 AC 641 ms
138,192 KB
testcase_26 AC 668 ms
138,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

n, p, q = map(int, input().split())
a = list(map(int, input().split()))

num10, num9, num7, num5 = 1, 1, 1, 1
d10, d9, d7, d5 = [0] * (2 * 10**6 + 2), [0] * (2 * 10 **
                                                6 + 2), [0] * (2 * 10**6 + 2), [0] * (2 * 10**6 + 2)
for i in range(1, 2 * 10**6 + 2):
    num10 = num10 * 10 % p
    num9 = num9 * 9 % p
    num7 = num7 * 7 % p
    num5 = num5 * 5 % p
    d10[i] = num10
    d9[i] = num9
    d7[i] = num7
    d5[i] = num5

a.sort()

ans = 0
for i1 in range(n - 3):
    for i2 in range(i1 + 1, n - 2):
        for i3 in range(i2 + 1, n - 1):
            for i4 in range(i3 + 1, n):
                if (d10[a[i1]] + d9[a[i2]] + d7[a[i3]] + d5[a[i4]]) % p == q:
                    ans += 1

print(ans)
0