Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int countPairs(vector<int>& deliciousness) {
- unordered_map<int, int> counter;
- long long ans=0, mod=int(1e9)+7;
- for(int d: deliciousness){
- for(int i=1, sum=1; i<=22; i++, sum*=2)
- if(counter.count(sum-d))
- ans = (ans + counter[sum-d])%mod;
- counter[d]++;
- }
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement