#C8428. Longest Power of Two Subsequence Count
Longest Power of Two Subsequence Count
Longest Power of Two Subsequence Count
You are given an array of n integers. Your task is to determine the length of the subsequence that consists solely of numbers which are powers of two. A number n is considered a power of two if it can be represented as \(2^k\) for some non-negative integer \(k\), i.e. it satisfies the condition \(n \neq 0\) and \(n \& (n-1) = 0\).
Note: In this problem, the subsequence is not necessarily contiguous; it is simply the count of all numbers in the array that are powers of two.
inputFormat
The input is read from stdin and it consists of two lines:
- The first line contains an integer \(n\) representing the number of elements in the array.
- The second line contains \(n\) space-separated integers.
outputFormat
Output to stdout a single integer which is the count of numbers in the array that are powers of two.
## sample6
1 8 4 16 2 32
6