結果
問題 |
No.2709 1975 Powers
|
ユーザー |
![]() |
提出日時 | 2024-03-31 14:08:49 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 654 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 82,056 KB |
実行使用メモリ | 82,368 KB |
最終ジャッジ日時 | 2024-09-30 19:02:34 |
合計ジャッジ時間 | 3,173 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 WA * 16 |
ソースコード
N,P,Q=map(int, input().split()) A=list(map(int, input().split())) A=sorted(A) ans=0 D,E={},{} for i in range(N-1): for j in range(i+1,N): a=pow(10,A[i],P) b=pow(9,A[j],P) ab=(a+b)%P c=pow(7,A[i],P) d=pow(5,A[j],P) cd=(c+d)%P if ab not in D: D[ab]=[] D[ab].append(j) if cd not in E: E[cd]=[] E[cd].append(i) for e in E: E[e]=sorted(E[e]) import bisect for d in D: q=Q-d if q in E: for now in D[d]: c=bisect.bisect_right(E[q],now) ans+=len(E[q])-c q=2*Q-d if q in E: for now in D[d]: c=bisect.bisect_right(E[q],now) ans+=len(E[q])-c print(ans)