結果
問題 | No.2709 1975 Powers |
ユーザー |
|
提出日時 | 2024-03-31 14:55:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,844 ms / 2,000 ms |
コード長 | 1,122 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 81,208 KB |
最終ジャッジ日時 | 2024-09-30 20:07:16 |
合計ジャッジ時間 | 22,663 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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_rightN, P, Q = MI()A = LI()mod5s = [0] * Pcnt5s = [[] for _ in range(P)]for i in range(N):mod5s[pow(5, A[i], P)] += 1cnt5s[pow(5, A[i], P)].append(A[i])for i in range(P):cnt5s[i].sort()ans = 0for i in range(N):for j in range(N):for k in range(N):if not (A[i] < A[j] and A[j] < A[k]):continuep10 = pow(10, A[i], P)p9 = pow(9, A[j], P)p7 = pow(7, A[k], P)three_mod = (p10 + p9 + p7) % Pres = (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)