[Solution] Fishingprince Plays With Array Codeforces Solution
Fishingprince is playing with an array . He also has a magic number .
He can do the following two operations on it:
- Select such that is divisible by (that is, there exists an integer such that ). Replace with copies of . The order of the other elements doesn't change. For example, when and and , changes into .
- Select such that . Replace these elements with a single . The order of the other elements doesn't change. For example, when and and , changes into .
Note that the array length might change during the process. The value of above is defined as the current length of the array (might differ from the in the input).
Fishingprince has another array . Please determine if he can turn into using any number (possibly zero) of operations.
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains two integers and (, ).
The second line of each test case contains integers ().
The third line of each test case contains one integer ().
The fourth line of each test case contains integers ().
It is guaranteed that the sum of over all test cases does not exceed .
For each testcase, print Yes if it is possible to turn into , and No otherwise. You can print each letter in any case (upper or lower).
No comments:
Post a Comment