Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array aa consisting

time limit per test

3 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given an array aa consisting of nn positive integers. You can perform operations on it.

In one operation you can replace any element of the array aiai with ai2ai2, that is, by an integer part of dividing aiai by 22 (rounding down).

See if you can apply the operation some number of times (possible 00) to make the array aa become a permutation of numbers from 11 to nn that is, so that it contains all numbers from 11 to nn, each exactly once.

For example, if a=[1,8,25,2]a=[1,8,25,2], n=4n=4, then the answer is yes. You could do the following:

  1. Replace 88 with 82=482=4, then a=[1,4,25,2]a=[1,4,25,2].
  2. Replace 2525 with 252=12252=12, then a=[1,4,12,2]a=[1,4,12,2].
  3. Replace 1212 with 122=6122=6, then a=[1,4,6,2]a=[1,4,6,2].
  4. Replace 66 with 62=362=3, then a=[1,4,3,2]a=[1,4,3,2].

Input

The first line of input data contains an integer tt (1t1041t104) the number of test cases.

Each test case contains exactly two lines. The first one contains an integer nn (1n501n50), the second one contains integers a1,a2,,ana1,a2,,an (1ai1091ai109).

Output

For each test case, output on a separate line:

  • YES if you can make the array aa become a permutation of numbers from 11 to nn,
  • NO otherwise.

You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).

image text in transcribed

Example input Copy 6 1 8 25 2 11 9 9 9 8 3 4 2 7 1 5 6 3 8 2 1 4 24 7 16 7 5 22 6 22 4 22 output | Copy YES NO YES NO NO YES Note The first test case is explained in the text of the problem statement. In the second test case, it is not possible to get a permutation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

4. I can tell when team members dont mean what they say.

Answered: 1 week ago

Question

2. How were various roles filled?

Answered: 1 week ago