結果
問題 | No.2709 1975 Powers |
ユーザー |
![]() |
提出日時 | 2024-04-30 00:26:35 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,319 bytes |
コンパイル時間 | 427 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 443,904 KB |
最終ジャッジ日時 | 2024-11-19 10:16:36 |
合計ジャッジ時間 | 44,786 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 TLE * 10 |
ソースコード
from heapq import heappush, heappop, heapifyimport sysfrom collections import defaultdict, deque,Counterfrom math import ceil, floor, sqrt, factorial,gcdfrom itertools import permutations, combinations,productfrom bisect import bisect_left, bisect_rightfrom copy import deepcopyfrom functools import lru_cache #@lru_cache(maxsize=None)from fractions import Fractionsys.setrecursionlimit(10**6)# input = sys.stdin.readlinevector1 = [[0, -1], [1, 0], [0, 1], [-1, 0]]vector2 = [[0, 1], [1, 0], [-1, 0], [0, -1],[1,-1], [-1, 1], [1, 1], [-1, -1]]from copy import deepcopydef main():N,P,Q = map(int,input().split())A = list(map(int,input().split()))A.sort()array = [[0 for i in range(P)]]for i in range(N):m = pow(5,A[i],P)tmp = deepcopy(array[-1])tmp[m] += 1array.append(tmp)ans = 0#print(array)for i in range(N-3):for j in range(i+1,N-2):if A[i] == A[j]:continuefor k in range(j+1,N-1):if A[j] == A[k]:continuet = (pow(10,A[i],P) + pow(9,A[j],P) + pow(7,A[k],P))%Pt = (Q-t)%Pans += array[-1][t]-array[k+1][t]print(ans)if __name__ == '__main__':main()