Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier — a machine which mutates minions.

Each minion has an intrinsic characteristic value (similar to our DNA), which is an integer. The transmogrifier adds an integer K to each of the minions' characteristic value. 

Gru knows that if the new characteristic value of a minion is divisible by 7, then it will have Wolverine-like mutations.

Given the initial characteristic integers of N minions, all of which are then transmogrified, find out how many of them become Wolverine-like.

-----Input Format:-----
The first line contains one integer, T, which is the number of test cases. Each test case is then described in two lines.
The first line contains two integers N and K, as described in the statement.
The next line contains N integers, which denote the initial characteristic values for the minions.

-----Output Format:-----
For each testcase, output one integer in a new line, which is the number of Wolverine-like minions after the transmogrification.

-----Constraints:-----
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 100
- 1 ≤ K ≤ 100
- All initial characteristic values lie between 1 and 105, both inclusive.

-----Example-----
Input:
1
5 10
2 4 1 35 1

Output:
1

-----Explanation:-----
After transmogrification, the characteristic values become {12,14,11,45,11}, out of which only 14 is divisible by 7. So only the second minion becomes Wolverine-like.

Source: codechef | Difficulty: EASY
Tags: Number theory

Mathematics

Complete search


Solutions:
t = int(input())
for i in range(t):
	a = [int(i) for i in input().split()]
	b = a[1]
	a = [int(i) for i in input().split()]
	k = 0
	for i in a:
		if (i + b) % 7 == 0:
			k = k + 1
	print(k)


for i in range(int(input())):
	a = 0
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	lst = map(lambda x: x + k, lst)
	for j in lst:
		if j % 7 == 0:
			a += 1
	print(a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	c = 0
	for j in x:
		j += k
		if j % 7 == 0:
			c += 1
	print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = 0
	for x in map(int, input().split()):
		if (x + k) % 7 == 0:
			ans += 1
	print(ans)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	z = list(map(int, input().split()))
	count = 0
	j = 0
	while j < x:
		if (z[j] + y) % 7 == 0:
			count += 1
		j += 1
	print(count)
	j = 0
	count = 0


for i in range(int(input())):
	(n, x) = map(int, input().split())
	y = list(map(int, input().split()))
	c = 0
	for i in range(n):
		a = y[i] + x
		if a % 7 == 0:
			c = c + 1
	print(c)


t = int(input())
for t in range(t):
	(n, k) = map(int, input().split())
	minions = list(map(int, input().split()))
	wolverines = 0
	for n in range(n):
		minions[n] += k
		if minions[n] % 7 == 0:
			wolverines += 1
	print(wolverines)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(len(l)):
		l[i] = l[i] + k
	l1 = l
	count = 0
	for i in range(len(l)):
		if l[i] % 7 == 0:
			count = count + 1
	print(count)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(input().split())
	count = 0
	for j in range(n):
		if (int(a[j]) + k) % 7 == 0:
			count += 1
	print(count)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l1 = [x + k for x in l1 if (x + k) % 7 == 0]
	print(len(l1))


t = int(input())
while t > 0:
	l = 0
	t = t - 1
	(a, b) = map(int, input().split())
	r = list(input().split())
	for i in range(a):
		r[i] = int(r[i]) + b
		if r[i] % 7 == 0:
			l = l + 1
	print(l)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = []
	count = 0
	for j in list1:
		a = j + k
		list2.append(a)
	for b in list2:
		if b % 7 == 0:
			count = count + 1
	print(count)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = len(a)
	cnt = 0
	for i in range(s):
		if (a[i] + k) % 7 == 0:
			cnt += 1
	print(cnt)


for i in range(int(input())):
	(N, T) = map(int, input().split())
	L = list(map(int, input().split()))
	count = 0
	for i in L:
		if (i + T) % 7 == 0:
			count += 1
	print(count)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	for i in l:
		if (i + b) % 7 == 0:
			c = c + 1
	print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	for i in l:
		if (i + k) % 7 == 0:
			c += 1
	print(c)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))[:n]
	count = 0
	for j in range(n):
		if (lst[j] + k) % 7 == 0:
			count += 1
		else:
			pass
	print(count)


try:
	for _ in range(int(input())):
		(N, K) = map(int, input().split())
		K = K % 7
		memory = list(map(int, input().split()))
		memory = list(map(lambda x: x + K, memory))
		memory = list(map(lambda x: x % 7, memory))
		print(memory.count(0))
except:
	pass


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = input().split()
	c = 0
	for j in a:
		v = int(j)
		if (v + k) % 7 == 0:
			c += 1
	print(c)


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	m = list(map(int, input().split()))
	m1 = list(map(lambda x: x + b, m))
	c = 0
	for i in m1:
		if i % 7 == 0:
			c += 1
	print(c)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	cnt = 0
	for val in arr:
		if (val + k) % 7 == 0:
			cnt += 1
	print(cnt)
	t -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	s = []
	for i in l:
		s.append(i + k)
	count = 0
	for i in s:
		if i % 7 == 0:
			count += 1
	print(count)


t = int(input())
for tc in range(t):
	(a, b) = map(int, input().split())
	li = list(map(int, input().split()))
	count = 0
	for i in range(a):
		li[i] += b
		if li[i] % 7 == 0:
			count += 1
	print(count)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = list(map(int, input().split()))
	for i in range(len(s)):
		s[i] += k
	res = 0
	for i in range(len(s)):
		if s[i] % 7 == 0:
			res += 1
	print(res)


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	arr = [int(k) for k in input().split()]
	ct = 0
	for i in arr:
		if (i + k) % 7 == 0:
			ct += 1
	print(ct)
	t -= 1


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	lst = list(map(int, input().strip().split()))
	count = 0
	for i in range(len(lst)):
		e = lst[i]
		e += K
		if e % 7 == 0:
			count += 1
	print(count)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	new = []
	count = 0
	for i in arr:
		new.append(i + k)
	for i in new:
		if i % 7 == 0:
			count += 1
	print(count)


for _ in range(int(input())):
	count = 0
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	for i in lis:
		i += k
		if i % 7 == 0:
			count += 1
	print(count)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	for i in range(n):
		if (a[i] + k) % 7 == 0:
			c = c + 1
		else:
			pass
	print(int(c))


for item in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	co = 0
	for i in range(n):
		if (a[i] + k) % 7 == 0:
			co = co + 1
		else:
			co = co + 0
	print(co)


T = int(input())
for i in range(T):
	count = 0
	(N, K) = map(int, input().split())
	L = list(map(int, input().split()))
	new_L = [j + K for j in L]
	for wol in new_L:
		if wol % 7 == 0:
			count += 1
	print(count)


for t in range(int(input())):
	ip = list(map(int, input().split()))
	k = ip[1]
	array = list(map(int, input().split()))
	wolv = 0
	for i in range(ip[0]):
		array[i] += k
		if array[i] % 7 == 0:
			wolv += 1
	print(wolv)


def __starting_point():
	for i in range(int(input())):
		(N, K) = map(int, input().split())
		count = 0
		N = list(map(int, input().split()))
		print(sum([True for x in N if (K + x) % 7 == 0]))
__starting_point()


try:
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		l = list(map(int, input().split()))
		count = 0
		for i in l:
			if (i + k) % 7 == 0:
				count += 1
		print(count)
except:
	pass


a = int(input())
for i in range(a):
	(b, c) = map(int, input().split())
	l = list(map(int, input().split()))
	if len(l) == b:
		d = 0
		for r in l:
			r = r + c
			if r % 7 == 0:
				d += 1
		print(d)
	else:
		print('WARNING')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l = [x + k for x in l]
	count = 0
	for i in l:
		if i % 7 == 0:
			count += 1
		else:
			continue
	print(count)


T = int(input())
for i in range(T):
	(N, K) = map(int, input().split())
	count = 0
	arr = list(map(int, input().split()))
	for u in arr:
		if (u + K) % 7 == 0:
			count += 1
	print(count)


T = int(input())
for t in range(T):
	minions = []
	count = 0
	(N, K) = input().split()
	N = int(N)
	K = int(K)
	mini = input().split()
	for num in mini:
		if num == ' ':
			continue
		else:
			minions.append(int(num))
	for minion in minions:
		M = minion + K
		if M % 7 == 0:
			count += 1
		else:
			continue
	print(count)


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	w = list(map(int, input().split()))
	w_n = list(map(lambda x: x + k, w))
	z = 0
	for i in range(len(w_n)):
		if w_n[i] % 7 == 0:
			z = z + 1
	print(z)


t = int(input())
for _ in range(t):
	(num_minions, added) = map(int, input().split())
	arr = list(map(int, input().split()))
	answer = 0
	for minion in arr:
		if (minion + added) % 7 == 0:
			answer += 1
	print(answer)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = [i + k for i in l]
	count = 0
	for j in m:
		if j % 7 == 0:
			count += 1
	print(count)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	P = []
	c = 0
	for i in p:
		P.append(i + k)
	for j in P:
		if j % 7 == 0:
			c = c + 1
	print(c)


a = int(input())
for i in range(a):
	b = [int(x) for x in input().split()]
	c = [int(y) for y in input().split()]
	d = sum((1 for i in c if (i + b[1]) % 7 == 0))
	print(d)


test = int(input())
for _ in range(0, test):
	(n, k) = list(map(int, input().split()))
	lister = list(map(int, input().split()))
	count = 0
	for x in lister:
		num = x + k
		if num % 7 == 0:
			count += 1
	print(count)


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	Nm = map(int, input().split())
	mutated = 0
	transmogrifier = [i + K for i in Nm]
	for i in transmogrifier:
		if i % 7 == 0:
			mutated += 1
	print(mutated)


for _ in range(int(input())):
	(onci, mati) = map(int, input().split())
	l1 = list(map(int, input().split()))
	cnt = 0
	for i in range(onci):
		if (l1[i] + mati) % 7 == 0:
			cnt += 1
	print(cnt)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	mut = list(map(int, input().split()))
	count = 0
	for item in mut:
		if (item + k) % 7 == 0:
			count += 1
		else:
			count += 0
	print(count)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	N = list(map(int, input().split()))
	s = 0
	for i in range(n):
		p = N[i] + k
		if p % 7 == 0:
			s += 1
		else:
			continue
	print(s)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l1 = [int(x) for x in input().split()]
	count = 0
	l2 = []
	for val in l1:
		l2.append(val + k)
	for i in range(0, len(l2)):
		if l2[i] % 7 == 0:
			count = count + 1
	print(count)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	w = 0
	for i in range(n):
		a[i] = a[i] + k
		if a[i] % 7 == 0:
			w = w + 1
	print(w)


t = int(input())
while t:
	(N, K) = map(int, input().split())
	c = 0
	min = list(map(int, input().split()))
	for i in range(N):
		if (K + min[i]) % 7 == 0:
			c = c + 1
	print(c)
	t = t - 1


for i in range(int(input())):
	yy = input()
	y = [int(e) for e in yy.split()]
	zz = input()
	z = [int(e) for e in zz.split()]
	count = 0
	for i in z:
		a = i + y[1]
		if a % 7 == 0:
			count += 1
	print(count)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		lst[i] += k
		if lst[i] % 7 == 0:
			flag += 1
	print(flag)


n = int(input())
for i in range(n):
	(p, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	m = 0
	for j in arr:
		if (j + q) % 7 == 0:
			m += 1
	print(m)


n = int(input())
for i in range(0, n):
	(a, b) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	l = [i + b for i in l]
	count = 0
	for i in l:
		if i % 7 == 0:
			count += 1
	print(count)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = map(int, input().split())
	count = 0
	for k in x:
		if (k + b) % 7 == 0:
			count += 1
	print(count)


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	wolverine = 0
	for i in range(N):
		if (A[i] + K) % 7 == 0:
			wolverine += 1
	print(wolverine)


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	c = 0
	for i in a:
		aa = i + k
		if aa % 7 == 0:
			c += 1
	print(c)


t = int(input())
for i in range(t):
	cn = 0
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(len(l)):
		l[i] += b
	for j in l:
		if j % 7 == 0:
			cn += 1
	print(cn)