-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathez pti.cpp
More file actions
44 lines (37 loc) · 785 Bytes
/
ez pti.cpp
File metadata and controls
44 lines (37 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int binser(int a[], int l, int r, int x){
if(r>=l){
int mid= (l+r)/2;
if(a[mid]==x) return mid;
if(a[mid]<x) return binser(a, mid+1, r, x);
if(a[mid]>x) return binser(a, l, mid-1, x);
}
return -1;
}
int main(){
int n;
scanf("%d", &n);
for(int i=0; i<n; ++i){
scanf("%d", &a[i]);
}
sort(a, a+n);
int ada=0;
for(int i=0; i<n; ++i){
for(int j=0; j<32; ++j){
long long x = (1ll<<j)-a[i];
int index = binser(a, index + 1, n-1, x);
int found = 0;
if(index > 0 && index != i){
found = 1;
}
index = binser(a, 0, index - 1, n-1, x);
if (index > 0 && index != i){
found = 1;
}
ada += found;
}
}
printf("%d", n-ada);
}