brute force greedy implementation *1300

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
typedef    long long int   ll;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll test,h,p,i,j,s,xy,n,flag=0,u,count,d,o1=0,o2=0,e,l,r,x,y,m,z,max1,x1,y1,k,x2,y2,z1,z2,sum,min1;
cin>>n;
vector<ll>a(n);
map<ll,ll>mk;
for(i=0;i<n;i++){
    cin>>a[i];
    mk[a[i]]++;
}
sum=0;
for(i=0;i<n;i++){
    mk[a[i]]--;
    flag=1;
    for(j=0;j<32;j++){
        if(mk[pow(2,j)-a[i]]>=1){
            flag=0;
        }
    }
    mk[a[i]]++;
    sum+=flag;
}
cout<<sum<<"\n";
return 0;
}


Comments

Submit
0 Comments
More Questions

842B - Gleb And Pizza
1746D - Paths on the Tree
1651E - Sum of Matchings
19A - World Football Cup
630P - Area of a Star
1030C - Vasya and Golden Ticket
1529D - Kavi on Pairing Duty
1743A - Password
1743B - Permutation Value
1743C - Save the Magazines
1743D - Problem with Random Tests
1070K - Video Posts
767C - Garland
1201B - Zero Array
1584C - Two Arrays
1131C - Birthday
1285B - Just Eat It
1743F - Intersection and Union
771A - Bear and Friendship Condition
1208E - Let Them Slide
656A - Da Vinci Powers
1025A - Doggo Recoloring
257A - Sockets
231C - To Add or Not to Add
1454E - Number of Simple Paths
931B - World Cup
934B - A Prosperous Lot
999B - Reversing Encryption
1238D - AB-string
810B - Summer sell-off