結果

問題 No.2709 1975 Powers
ユーザー konchakoncha
提出日時 2024-03-31 14:22:56
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 972 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 95,560 KB
最終ジャッジ日時 2024-03-31 14:23:00
合計ジャッジ時間 4,292 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
61,012 KB
testcase_01 AC 47 ms
61,012 KB
testcase_02 RE -
testcase_03 AC 131 ms
76,668 KB
testcase_04 RE -
testcase_05 AC 141 ms
76,728 KB
testcase_06 RE -
testcase_07 AC 76 ms
78,888 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 108 ms
93,472 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 106 ms
80,088 KB
testcase_15 AC 98 ms
77,064 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from copy import copy


def maker(l, x):
    current = (l[-1]*x) % P
    for i, item in enumerate(l):
        if item == current:
            return (l[:i], l[i:])
    return maker(l+[current], x)


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

A.sort()

lo = []
for x in [10, 9, 7, 5]:
    loops = maker([x%P], x)
    lo.append([])

    for a in A:
        a -= 1
        if len(loops[0]) > a:
            lo[-1].append(loops[0][a])
        a -= len(loops[0])
        lo[-1].append(loops[1][a%len(loops[1])])

clo = [Counter(l) for l in lo]
answer = 0

clo3 = clo[3]

for i in range(N):
    x = lo[0][i]
    clo3[lo[3][i]] -= 1

    tmp = copy(clo3)

    for j in range(i+1, N):
        tmp[lo[3][j]] -= 1
        for k in range(j+1, N):
            tmp[lo[3][k]] -= 1
            answer += tmp.get((Q-(x+lo[1][j]+lo[2][k])) % P, 0)

        for k in range(j+1, N):
            tmp[lo[3][k]] += 1

print(answer)
0