303632: CF702B. Powers of Two

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Powers of Two

题意翻译

给一个长度为$n$的序列$a$ 从中选取$a_i,a_j$,使$a_i+a_j=2^x,(x\in N^* ,i<j)$ 求序列中有多少对这样的数 $P.S$: 样例1:有$(1,4),(2,4)$两对数

题目描述

You are given $ n $ integers $ a_{1},a_{2},...,a_{n} $ . Find the number of pairs of indexes $ i,j $ ( $ i&lt;j $ ) that $ a_{i}+a_{j} $ is a power of $ 2 $ (i. e. some integer $ x $ exists so that $ a_{i}+a_{j}=2^{x} $ ).

输入输出格式

输入格式


The first line contains the single positive integer $ n $ ( $ 1<=n<=10^{5} $ ) — the number of integers. The second line contains $ n $ positive integers $ a_{1},a_{2},...,a_{n} $ ( $ 1<=a_{i}<=10^{9} $ ).

输出格式


Print the number of pairs of indexes $ i,j $ ( $ i&lt;j $ ) that $ a_{i}+a_{j} $ is a power of $ 2 $ .

输入输出样例

输入样例 #1

4
7 3 2 1

输出样例 #1

2

输入样例 #2

3
1 1 1

输出样例 #2

3

说明

In the first example the following pairs of indexes include in answer: $ (1,4) $ and $ (2,4) $ . In the second example all pairs of indexes $ (i,j) $ (where $ i&lt;j $ ) include in answer.

Input

题意翻译

给一个长度为$n$的序列$a$ 从中选取$a_i,a_j$,使$a_i+a_j=2^x,(x\in N^* ,i<j)$ 求序列中有多少对这样的数 $P.S$: 样例1:有$(1,4),(2,4)$两对数

加入题单

上一题 下一题 算法标签: