//土尔逊Torson 编写于2023/4/14 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> #include <algorithm> #include <stdlib.h> using namespace std; int arr[101]; bool comp0321(int left, int right) { if (left < right) { return true; } else { return false; } } bool BinarySearch(int n, int target) { int left = 0; int right = n - 1; while (left <= right) { int middle = (left + right) / 2; if (arr[middle] < target) { left = middle + 1; } else if (target < arr[middle]) { right = middle - 1; } else { return true; } } return false; } int main() { int n, m; while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; ++i) { scanf("%d", &arr[i]); } sort(arr, arr + n, comp0321); scanf("%d", &m); for (int i = 0; i < m; ++i) { int target; scanf("%d", &target); if (BinarySearch(n,target)) { printf("YES\n"); } else { printf("NO\n"); } } } system("pause"); return EXIT_SUCCESS; } // 64 位输出请用 printf("%lld")