Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Nikita is a student passionate about number theory and algorithms. He faces an interesting problem related to an array of numbers. Suppose Nikita has an
Nikita is a student passionate about number theory and algorithms. He faces an interesting problem related to an array of numbers.
Suppose Nikita has an array of integers a
of length n
He will call a subsequence
of the array special if its least common multiple LCM is not contained in a
The LCM of an empty subsequence is equal to
Nikita wonders: what is the length of the longest special subsequence of a
Help him answer this question!
A sequence b
is a subsequence of a
if b
can be obtained from a
by the deletion of several possibly zero or all elements, without changing the order of the remaining elements. For example,
is a subsequence of
Input
Each test contains multiple test cases. The first line of input contains a single integer t
t
the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer n
n
the length of the array a
The second line of each test case contains n
integers aaan
ai
the elements of the array a
It is guaranteed that the sum of n
over all test cases does not exceed
Output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started