Pythagos
unknown
c_cpp
2 years ago
824 B
2
Indexable
#include<bits/stdc++.h> using namespace std; bool check(vector<long long> v,int l,int r,long long x){ while(l <= r){ int mid = (l + r)/2; if(v[mid] == x) return true; else if(v[mid] > x) r = mid - 1; else l = mid + 1; } return false; } void solve(vector<long long> v){ int ok = 1; int n = v.size(); for(int i = 0;i < n;i++){ for(int j = i + 1;j < n;j++){ long long x = v[i] + v[j]; if(check(v,j+1,n-1,x)){ ok = 0; cout << "YES\n"; } } } if(ok) cout << "NO\n"; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while(t--){ int n; cin >> n; vector<long long> v; for(int i = 0;i < n;i++){ long long x; cin >> x; v.push_back(x*x); } sort(v.begin(),v.end()); solve(v); } }
Editor is loading...
Leave a Comment