#include<iostream> #include<cstring> using namespace std; int a[10000000],b[10000000] = { 0 }; int main() { int t, n, x; cin >> t; while (t--) { //int b[10000000] = { 0 }; //memset(b, 0, sizeof(b)); cin >> n >> x; for (int i = 0; i < n; i++) { cin >> a[i]; b[a[i]]++; } int flag = 0; for (int i = 0; i < n; i++) { if (b[x - a[i]] != 0&&x!=2*a[i]) { cout<<"YES"<<endl; break; } else if (b[x - a[i]] >=2) { cout<<"YES"<<endl; break; } } if(i==n) cout<<"NO"<<endl; } return 0; } /* Main.cc: In function 'int main()': Main.cc:29:6: error: 'i' was not declared in this scope if(i==n) cout<<"NO"<<endl; ^ Main.cc:18:7: warning: unused variable 'flag' [-Wunused-variable] int flag = 0; ^ */ |
Double click to view unformatted code.