結果
問題 |
No.2709 1975 Powers
|
ユーザー |
![]() |
提出日時 | 2024-03-31 16:38:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 855 bytes |
コンパイル時間 | 360 ms |
コンパイル使用メモリ | 82,572 KB |
実行使用メモリ | 62,864 KB |
最終ジャッジ日時 | 2024-09-30 21:06:00 |
合計ジャッジ時間 | 2,982 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#MMA Contest 018 D N, P, Q = map(int, input().split()) A = sorted(map(int, input().split())) #事前に冪を求めておく #Aw + Ax + Ay + Az の順に対応させたいので、後はよしなに W = [pow(10, a, P) for a in A] X = [pow( 9, b, P) for b in A] Y = [pow( 7, c, P) for c in A] Z = [pow( 5, d, P) for d in A] #Zを連想配列に変換 c < dとなるdであって、5^d = Zi となる個数 D = dict() for Zi in Z: if Zi not in D: D[Zi] = 0 D[Zi] += 1 ans = 0 for c in range(N): y = Y[c] D[ Z[c] ] -= 1 for b in range(c): x = X[b] for a in range(b): assert a < b < c w = W[a] #w + x + y + z ≡ Q mod P #z = Q - (w + x + y) mod P z = Q - (w + x + y) z %= P if z in D: ans += D[z] print(ans)