atcoder#AGC029B. [AGC029B] Powers of two
[AGC029B] Powers of two
Score : points
Problem Statement
Takahashi has balls with positive integers written on them. The integer written on the -th ball is . He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of . Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed.
Here, a positive integer is said to be a power of when it can be written as using some non-negative integer .
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of .
3
1 2 3
1
We can form one pair whose sum of the written numbers is by pairing the first and third balls. Note that we cannot pair the second ball with itself.
5
3 11 14 5 13
2