Dcoder Logo

Double the Number @ Dcoder

By Lochard | As a newbie programmer | 15 Feb 2023


Problem: Given an array A of size N and K. count all the number of elements such that A[i] * 2 = K.

Input: The first line of the input contains a single integer T denoting the number of test cases.

The first line of each test case contains two space separated integer N and K respectively.

The second line of each test case contains N space separated integers A[i].

Output: For each test case, print a single line containing count.

Constraints: 1 <= T <= 10

1 <= N, K <= 100

1 <= A[i] <= 100

Sample Input: 1

7 14

14 37 7 7 7 40 44

Sample Output: 

3

for i in range(int(input())):
  k = int(input().split()[1])
  a = list(map(lambda x: int(x) * 2, input().split()))
  print(a.count(k))

How do you rate this article?

2


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.