結果

問題 No.2260 Adic Sum
ユーザー shobonvipshobonvip
提出日時 2023-04-07 21:25:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 946 ms / 2,000 ms
コード長 1,769 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,652 KB
実行使用メモリ 211,384 KB
最終ジャッジ日時 2024-04-15 23:37:58
合計ジャッジ時間 8,856 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,888 KB
testcase_01 AC 44 ms
54,528 KB
testcase_02 AC 45 ms
53,888 KB
testcase_03 AC 46 ms
54,144 KB
testcase_04 AC 45 ms
54,272 KB
testcase_05 AC 47 ms
54,528 KB
testcase_06 AC 46 ms
54,016 KB
testcase_07 AC 45 ms
54,656 KB
testcase_08 AC 59 ms
64,896 KB
testcase_09 AC 56 ms
63,232 KB
testcase_10 AC 59 ms
64,896 KB
testcase_11 AC 46 ms
55,168 KB
testcase_12 AC 62 ms
66,048 KB
testcase_13 AC 57 ms
64,640 KB
testcase_14 AC 77 ms
80,116 KB
testcase_15 AC 85 ms
87,168 KB
testcase_16 AC 70 ms
77,184 KB
testcase_17 AC 89 ms
89,344 KB
testcase_18 AC 537 ms
196,828 KB
testcase_19 AC 559 ms
190,244 KB
testcase_20 AC 369 ms
157,820 KB
testcase_21 AC 365 ms
157,964 KB
testcase_22 AC 319 ms
142,324 KB
testcase_23 AC 232 ms
117,056 KB
testcase_24 AC 541 ms
177,296 KB
testcase_25 AC 107 ms
104,320 KB
testcase_26 AC 104 ms
100,736 KB
testcase_27 AC 107 ms
104,320 KB
testcase_28 AC 107 ms
103,936 KB
testcase_29 AC 106 ms
104,168 KB
testcase_30 AC 126 ms
96,768 KB
testcase_31 AC 513 ms
98,944 KB
testcase_32 AC 450 ms
98,816 KB
testcase_33 AC 125 ms
95,488 KB
testcase_34 AC 265 ms
142,296 KB
testcase_35 AC 946 ms
211,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
	newlines = 0
	
	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = "x" in file.mode or "r" not in file.mode
		self.write = self.buffer.write if self.writable else None
	
	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()
	
	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b"\n")+(not b)
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1
		return self.buffer.readline()
	
	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s:self.buffer.write(s.encode("ascii"))
		self.read = lambda:self.buffer.read().decode("ascii")
		self.readline = lambda:self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda:sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict
n,p = map(int,input().split())
a = list(map(int,input().split()))

t = defaultdict(int)

ans = 0
for i in range(n):
	for j in range(1, 35):
		g = p ** j
		if g > 10 ** 9: break
		ans += t[(j << 30) + a[i] % g]
		t[(j << 30) + a[i] % g] += 1

print(ans)
0