#include <stdio.h>
#include <algorithm>
using namespace std;
int arr[1000010];
int main() {
int n, m;
scanf("%d", &n);
for(int i=0; i<n; i++) {
scanf("%d", &arr[i]);
}
sort(arr, arr + n);
scanf("%d", &m);
for(int j=1; j<=m; j++) {
int k;
scanf("%d", &k);
int low=0, high=n-1, flag=0;
while(low<=high) {
int mid=(low+high)/2;
if(arr[mid]>k) high=mid-1;
else if(arr[mid]==k) {
flag=1;
break;
}
else low=mid+1;
}
printf("%d\n", flag);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: