-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathC.cpp
50 lines (41 loc) · 945 Bytes
/
C.cpp
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
45
46
47
48
49
50
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll ara[200009];
int main()
{
ll n;
cin >> n;
for(ll i = 0; i < n; i++) {
scanf("%lld", &ara[i]);
}
ll mv = 0;
sort(ara, ara + n);
for(ll i = 0; i < n; i++) {
ll x = ara[i];
ll pw = 2;
bool check = 0;
for(ll j = 1; j <= 40; j++) {
if(pw <= x) {
pw *= 2;
continue;
}
ll dif = pw - x;
//cout << x << " " << dif << endl;
ll pos = lower_bound(ara, ara + n, dif) - ara;
if(ara[pos] == dif) {
if(ara[pos] == x) {
if(ara[pos + 1] == x)
check = 1;
}
else
check = 1;
}
pw *= 2;
}
if(!check)
mv++;
}
cout << mv << endl;
return 0;
}