
Rabbit Jumping Problem
Consider 'n' carrots numbered from 1 to 'n' and 'k' rabbits. Each rabbit jumps to carrots only at multiples of its respective jumping factor Aj (i.e., Aj, 2Aj, 3Aj, ...), for all rabbits from 1 to k.
When a rabbit reaches a carrot, it eats a little portion of it. All rabbits start from the same starting point. Your task is to determine and return the total count of carrots that remain uneaten after all rabbits have finished jumping.
Input:
The first line contains an integer 'T' indicating the number of test cases.
Each test case comprises two lines.
First line: two integers 'n' and 'k' indicating the number of carrots and rabbits.
Second line: 'k' space-separated integers representing the jumping factors of the rabbits.
Output:
A single integer for each test case indicating the number of carrots that were not eaten.
Example:
Input:
1
10 2
2 3
Output:
3
Explanation:
With 10 carrots and rabbits jumping on multiples of 2 and 3, carrots 2, 3, 4, 6, 8, 9, 10 will be eaten by the rabbits, leaving carrots 1, 5, and 7 uneaten.
Constraints:
- 1 <= 'T' <= 50
- 1 <= 'n', 'k' <= 3000
- 1 <= A[j] <= n, for all j from 1 to k
- Time Limit: 1 second


Calculate uneaten carrots by rabbits with specific jumping factors.
Iterate through each carrot and check if any rabbit jumps on it.
Use the jumping factors to determine which carrots will be eaten.
Subt...read more

Top DE Shaw Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in DE Shaw Software Developer
Reviews
Interviews
Salaries
Users/Month