結果
| 問題 | No.2709 1975 Powers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-31 13:42:32 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 596 bytes | 
| コンパイル時間 | 330 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 91,520 KB | 
| 最終ジャッジ日時 | 2024-09-30 18:17:10 | 
| 合計ジャッジ時間 | 23,541 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 9 WA * 16 | 
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#input = sys.stdin.readline
n,p,q = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
x = [[] for i in range(p)]
for i in range(n):
    x[pow(5,a[i],p)].append(i)
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            z = pow(10,a[i],p) + pow(9,a[j],p) + pow(7,a[k],p)
            z %= p
            r = (q - z) % p
            ans += len(x[r]) - bisect.bisect_right(x[r],k)
print(ans)
            
            
            
        