PROBLEM LINK:
[Contest] T23
Author: Nandishwar Garg
DIFFICULTY:
SIMPLE
PROBLEM:
You are given an array of size N. You have to find every possible subset of the elements in array. Then we have to check 3 conditions on these subsets:
- It should not be empty.
- It should not have any element in subset which divide other elements present in subset except 1.
- It should not have duplicate elements.
If it satisfies all the conditions then print yes otherwise print no.
EXPLANATION:
Suppose the array elements are 1,2 and 3. The subsets of these elements are {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}.
- None of these subsets are empty
- No element other than 1 is dividing another element
- No duplicate element is present.
So, you have to print yes.
Taking another example, the array elements are 2 and 4. The subsets of following elements are {2}, {4} and {2,4}.
- None of these subsets are empty
- In {2,4}, 2 is dividing 4 so it doesn’t satisfy the condition
Thus you have to print no as the output.
AUTHOR’S SOLUTIONS:
Author’s solution can be found here