Jumping Game Problem Statement
In this problem, you have ‘n’ carrots lined up and denoted by numbers 1 through ‘n’. There are ‘k’ rabbits, and each rabbit can jump to carrots that are multiples of its unique jumping factor.
Rabbits start from the same point, and each time a rabbit lands on a carrot, it eats some of it. Your task is to calculate how many carrots remain uneaten after all rabbits have finished jumping.
Input:
The first line contains an integer ‘T’, representing the number of test cases.
For each test case:
The first line contains two integers, ‘n’ and ‘k’, denoting the number of carrots and rabbits, respectively.
The second line contains ‘k’ space-separated integers; each integer is a rabbit's jumping factor.
Output:
Output a single integer for each test case, representing the number of carrots that remain uneaten.
Example:
Input:
1
10 2
2 3
Output:
3
Constraints:
- 1 ≤ ‘T’ ≤ 50
- 1 ≤ ‘n’, ‘k’ ≤ 3000
- 1 ≤ A[j] ≤ n, for all j from 1 to k
Note: You are not required to handle any input/output operations. Implement the given function to solve the problem.
Be the first one to answer
Add answer anonymously...
Top Nagarro Technical Trainee interview questions & answers
Popular interview questions of Technical Trainee
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app