AmazonOA #201
Get Max Discount Pairs
估计中等可在线判题
Count product pairs with distinct indices i<j such that price[i]+price[j] equals 3^e for some non-negative integer e, including 3^0=1. Different products with the same price are counted as different index combinations.
输入格式
The first line contains n; the second line contains the prices. This site uses 1≤n≤200000, 0≤price≤10^9.
输出格式
Output a single integer, the answer.
样例 1
输入:
3
2 1 8
输出:
2
样例 2
输入:
3
0 1 1
输出:
2
样例 3
输入:
4
1 1 2 2
输出:
4
样例说明
The answers are 2, 2 and 4.