https://codeforces.com/problemset/problem/1005/C
一、代码
目录
#include <bits/stdc++.h>
using namespace std;
void solve(){
int a[122222], n, ans = 0;
map<int, int> m;
scanf("%d", &n);
for (int i = 0;i < n;i ++){
scanf("%d", &a[i]);
m[a[i]] ++;
}
for (int i = 0;i < n;i ++){
bool flag = 1;
long long num = 1;
for (int j = 1;j <= 31;j ++){
int need = num - a[i];
if ((need == a[i] and m[need] >= 2) or (need != a[i] and m[need] >= 1)){
flag = 0;
break;
}
num *= 2;
}
ans += flag;
}
printf("%d", ans);
}
int main(){
int T;
T = 1;
while(T--) solve();
return 0;
}
// 该题方法与CSES-1640 相近