結果

問題 No.2709 1975 Powers
ユーザー KeeKee
提出日時 2024-03-31 22:58:22
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,280 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 82,556 KB
最終ジャッジ日時 2024-03-31 22:58:27
合計ジャッジ時間 4,298 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,608 KB
testcase_01 AC 44 ms
55,604 KB
testcase_02 AC 304 ms
76,008 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3

import bisect
import collections
import heapq
import itertools
import math
import os
import sys


def main():
    n, p, q = read_ints()
    A = read_ints()
    A.sort()
    print(rec(n, p, q, A, 0, 0, 0))


B = (10, 9, 7, 5)


def rec(n, p, q, A, i, c, s):
    if c == 4:
        if s == q:
            return 1
        return 0

    ans = 0
    for j in range(i, n - (3 - c)):
        ans += rec(n, p, q, A, j + 1, c + 1, (s + pow(B[c], A[j], p)) % p)

    return ans


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def list2d(d1, d2, init=None):
    return [[init] * d2 for _ in range(d1)]


def list3d(d1, d2, d3, init=None):
    return [[[init] * d3 for _ in range(d2)] for _ in range(d1)]


def list4d(d1, d2, d3, d4, init=None):
    return [[[[init] * d4 for _ in range(d3)] for _ in range(d2)]
            for _ in range(d1)]


def debug(fmt, *args):
    if DEBUG:
        if args:
            print(fmt.format(*args), file=sys.stderr)
        else:
            print(fmt, file=sys.stderr)


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