Untitled
unknown
plain_text
9 months ago
498 B
13
Indexable
N = int(input())
A = input().split()
prefix = [[0] * (N + 1) for _ in range(10)]
for i in range(N):
for d in range(10):
prefix[d][i + 1] = prefix[d][i]
for ch in A[i]:
prefix[int(ch)][i + 1] += 1
M = int(input())
results = []
count = 0
while count < M:
line = input().strip()
if line == "0":
continue
K, L, R = map(int, line.split())
results.append(prefix[K][R] - prefix[K][L])
count += 1
for res in results:
print(res)
Editor is loading...
Leave a Comment