結果

問題 No.2260 Adic Sum
ユーザー fiblonariafiblonaria
提出日時 2023-04-11 00:27:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 440 ms / 2,000 ms
コード長 240 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 178,172 KB
最終ジャッジ日時 2024-10-06 11:54:26
合計ジャッジ時間 5,888 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P = map(int, input().split())
A = list(map(int, input().split()))
ans, temp, M = 0, P, max(A)
while temp <= M:
	d = {}
	for i in A:
		d[i % temp] = d.get(i % temp, 0) + 1
	for i in d:
		ans += d[i] * (d[i] - 1) // 2
	temp *= P
print(ans)
0