[Solution] Equate Multisets Codeforces Solution
Multiset —is a set of numbers in which there can be equal elements, and the order of the numbers does not matter. Two multisets are equal when each value occurs the same number of times. For example, the multisets and are equal, but the multisets and — are not.
You are given two multisets and , each consisting of integers.
In a single operation, any element of the multiset can be doubled or halved (rounded down). In other words, you have one of the following operations available for an element of the multiset:
- or replace with ,
- or replace with (round down).
Note that you cannot change the elements of the multiset.
See if you can make the multiset become equal to the multiset in an arbitrary number of operations (maybe ).
For example, if , , , then the answer is yes. We can proceed as follows:
The first line of input data contains a single integer () —the number of test cases.
Round Down the Price Codeforces Solution
Polycarp Writes a String from Memory Codeforces Solution
Train and Queries Codeforces Solution
Not a Cheap String Codeforces Solution
Split Into Two Sets Codeforces Solution
Equate Multisets Codeforces Solution
Passable Paths (easy version) Codeforces Solution
Passable Paths (hard version) Codeforces Solution
Each test case consists of three lines.
The first line of the test case contains an integer () —the number of elements in the multisets and .
The second line gives integers: () —the elements of the multiset . Note that the elements may be equal.
The third line contains integers: () — elements of the multiset . Note that the elements may be equal.
It is guaranteed that the sum of values over all test cases does not exceed .
For each test case, print on a separate line:
- YES if you can make the multiset become equal to ,
- NO otherwise.
You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as positive answer).
No comments:
Post a Comment