For a given sequence A = { a 0 , a 1 , . . . , a n 1 } A = \{a_0, a_1, ..., a_{n-1}\} A={a0,a1,...,an1} which is sorted by ascending order, find a specific value k k k given as a query.

Input
The input is given in the following format.

n n n
a 0    a 1    , . . . ,    a n 1 a_0 \; a_1 \; ,..., \; a_{n-1} a0a1,...,an1
q q q
k 1 k_1 k1
k 2 k_2 k2
:
k q k_q kq
The number of elements n n n and each element a i a_i ai are given in the first line and the second line respectively. In the third line, the number of queries q q q is given and the following q q q lines, q q q integers k i k_i ki are given as queries.

Output
For each query, print 1 if any element in A A A is equivalent to k k k, and 0 otherwise.

Constraints
1 n 100 , 000 1 \leq n \leq 100,000 1n100,000
1 q 200 , 000 1 \leq q \leq 200,000 1q200,000
0 a 0 a 1 . . . a n 1 1 , 000 , 000 , 000 0 \leq a_0 \leq a_1 \leq ... \leq a_{n-1} \leq 1,000,000,000 0a0a1...an11,000,000,000
0 k i 1 , 000 , 000 , 000 0 \leq k_i \leq 1,000,000,000 0ki1,000,000,000
Sample Input 1

4
1 2 2 4
3
2
3
5

Sample Output 1

1
0
0

题意:
从长度为n的非递减序列里查找q次,每次查1个数,如果找到输出1,否则输出0

#include<bits/stdc++.h>
using namespace std;
int a[100005];
bool f(int a[],int n,int x){
	 int l=0,r=n-1,m;
	 while(r>l){
	 	m=(l+r)>>1;
	 	if(a[m]==x) return true;
	 	else if(a[m]>x) r=m-1;
	 	else l=m+1;	 
	 }
	 if(a[l]==x) return true;
	 else return false;
}
int main(){
	int n,m,x;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&m);
	while(m--){
		scanf("%d",&x);
		if(f(a,n,x)) printf("1\n");
		else printf("0\n");
	}
	return 0;
}