結果

問題 No.2709 1975 Powers
ユーザー ThetaTheta
提出日時 2024-04-10 15:34:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 674 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 82,412 KB
実行使用メモリ 88,892 KB
最終ジャッジ日時 2024-04-10 15:34:31
合計ジャッジ時間 25,687 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,952 KB
testcase_01 AC 35 ms
54,236 KB
testcase_02 AC 95 ms
76,828 KB
testcase_03 AC 1,219 ms
77,056 KB
testcase_04 AC 1,810 ms
79,776 KB
testcase_05 AC 1,393 ms
78,436 KB
testcase_06 AC 587 ms
79,872 KB
testcase_07 AC 42 ms
59,720 KB
testcase_08 AC 649 ms
87,704 KB
testcase_09 AC 1,404 ms
81,344 KB
testcase_10 AC 42 ms
60,032 KB
testcase_11 AC 142 ms
77,672 KB
testcase_12 AC 240 ms
83,456 KB
testcase_13 AC 1,479 ms
88,892 KB
testcase_14 AC 329 ms
78,148 KB
testcase_15 AC 451 ms
78,248 KB
testcase_16 AC 1,172 ms
78,952 KB
testcase_17 AC 74 ms
68,736 KB
testcase_18 AC 320 ms
85,280 KB
testcase_19 AC 1,818 ms
85,000 KB
testcase_20 AC 82 ms
78,056 KB
testcase_21 AC 585 ms
87,384 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

from itertools import combinations
import sys


def printe(*args, end="\n", **kwargs):
    print(*args, end=end, file=sys.stderr, **kwargs)


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

    mod_P_pow_5 = defaultdict(set)
    for a_elm in A:
        mod_P_pow_5[pow(5, a_elm, P)].add(a_elm)

    ctr = 0
    for a, b, c in combinations(A, 3):
        c_mod = (pow(10, a, P) + pow(9, b, P) + pow(7, c, P)) % P
        rest_mod = (Q - c_mod) % P
        ctr += len(list(filter(lambda elm: elm > c, mod_P_pow_5[rest_mod])))
    print(ctr)


if __name__ == "__main__":
    main()
0