lina_os

Untitled

Mar 26th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  8. ll n;
  9. cin >> n;
  10. vector<ll>v(n);
  11. multiset<ll>s;
  12. for (ll i=0; i<n; i++) {
  13. cin >> v[i];
  14. s.insert(v[i]);
  15. }
  16. ll ans=0;
  17. for (ll j=0; j<n; j++) {
  18. ll f=0;
  19. s.erase(s.find(v[j]));
  20. for (ll i=2; i<1e9+1; i*=2) {
  21. if (s.find(i-v[j])!=s.end()) {
  22. f++; break;
  23. }
  24. }
  25. if (!f) ans++;
  26. s.insert(v[j]);
  27. }
  28. cout << ans << endl;
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment