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.

AnswerBot
4mo
Calculate uneaten carrots after rabbits jump based on their unique factors.
Iterate through each rabbit's jumping factor and mark the carrots they land on as eaten
Calculate the remaining uneaten carrot...read more
Help your peers!
Add answer anonymously...
Nagarro Technical Trainee interview questions & answers
A Technical Trainee was asked Q. Detect and Remove Loop in Linked List For a given singly linked list, identify i...read more
A Technical Trainee was asked Q. Trapping Rainwater Problem Statement You are given an array ARR of long type, wh...read more
A Technical Trainee was asked Q. Spiral Order Traversal of a Binary Tree Given a binary tree with N nodes, your t...read more
Popular interview questions of Technical Trainee
A Technical Trainee was asked Q1. Detect and Remove Loop in Linked List For a given singly linked list, identify i...read more
A Technical Trainee was asked Q2. Trapping Rainwater Problem Statement You are given an array ARR of long type, wh...read more
A Technical Trainee was asked Q3. Spiral Order Traversal of a Binary Tree Given a binary tree with N nodes, your t...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

