Question: Write java to solve: You are given an array of integers 1 , 2 , . . . , a 1 , a 2 ,
Write java to solve: You are given an array of integers aaan of length n and an integer k
Two players are playing a game. The first player chooses an index in Then the second player chooses a different index jnij The first player wins if aiaj is not divisible by k Otherwise, the second player wins.
We play as the first player. Determine whether it is possible to win, and if so which index i should be chosen.
The absolute value of a number x is denoted by x and is equal to x if x and x otherwise.
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 two integers n and k n; k the length of the array and the number k
The second line of each test case contains integers aaan ai the elements of the array
Output
For each test case, if it is impossible for the first player to win, print NOwithout quotes
Otherwise, print "YES" without quotes and on the next line the appropriate index in If there are multiple solutions, print any of them.
Example
Input
Output
YES NO YES NO NO YES YES
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
