結果
問題 |
No.2709 1975 Powers
|
ユーザー |
|
提出日時 | 2024-03-31 15:01:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 231 ms / 2,000 ms |
コード長 | 1,322 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 82,604 KB |
実行使用メモリ | 127,672 KB |
最終ジャッジ日時 | 2024-09-30 20:10:42 |
合計ジャッジ時間 | 4,695 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
# 標準入力された値を整数に変換する def INT(): return int(input()) # 標準入力された複数の値を整数に変換する def MI(): return map(int, input().split()) # 標準入力された複数の値を整数のリストに変換する def LI(): return list(map(int, input().split())) from bisect import bisect_right N, P, Q = MI() A = LI() mod10s = [0] * (max(A) + 1) mod9s = [0] * (max(A) + 1) mod7s = [0] * (max(A) + 1) mod5s = [0] * P cnt5s = [[] for _ in range(P)] for i in range(N): mod10s[A[i]] = pow(10, A[i], P) mod9s[A[i]] = pow(9, A[i], P) mod7s[A[i]] = pow(7, A[i], P) mod5s[pow(5, A[i], P)] += 1 cnt5s[pow(5, A[i], P)].append(A[i]) for i in range(P): cnt5s[i].sort() ans = 0 for i in range(N): for j in range(N): if A[i] >= A[j]: continue for k in range(N): if A[j] >= A[k]: continue p10 = mod10s[A[i]] p9 = mod9s[A[j]] p7 = mod7s[A[k]] three_mod = (p10 + p9 + p7) % P res = (Q - three_mod + P) % P # if len(cnt5s[res]) - bisect_right(cnt5s[res], A[k]): # print(A[k], cnt5s[res], bisect_right(cnt5s[res], A[k])) ans += len(cnt5s[res]) - bisect_right(cnt5s[res], A[k]) print(ans)