/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 66ms 564.0 KiB
#3 Accepted 66ms 568.0 KiB
#4 Accepted 66ms 540.0 KiB
#5 Accepted 66ms 540.0 KiB
#6 Accepted 68ms 568.0 KiB
#7 Accepted 18ms 540.0 KiB
#8 Accepted 18ms 540.0 KiB
#9 Accepted 19ms 540.0 KiB
#10 Accepted 19ms 540.0 KiB
#11 Accepted 18ms 540.0 KiB
#12 Accepted 19ms 1.277 MiB
#13 Accepted 19ms 1.277 MiB
#14 Accepted 129ms 1.312 MiB
#15 Accepted 129ms 1.277 MiB

Code

#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;

const int N = 1e8;

void solve() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++) {
        int pow2 = 2;
        while(pow2 <= N) {
            int a = v[i];
            int b = (pow2 - 1) - a;
            if(a == b) {
                auto it1 = lower_bound(v.begin(), v.end(), a);
                auto it2 = upper_bound(v.begin(), v.end(), b);
                if(it2 - it1 > 1) {
                    cout << 1 << endl;
                    return;
                }
            }
            else {
                if(binary_search(v.begin(), v.end(), b)) {
                    cout << 1 << endl;
                    return;
                }
            }
            pow2 *= 2;
        }
    }
    cout << 0 << endl;
    return;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case " << t << ": ";
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1175 Maximum binary product of sum pairs
Contest
Lu IEEE testing round
Language
C++17 (G++ 13.2.0)
Submit At
2025-02-24 21:41:26
Judged At
2025-02-24 21:41:26
Judged By
Score
100
Total Time
129ms
Peak Memory
1.312 MiB