显示代码纯文本
#include<stdio.h>
int n,m[1500002],i,k,a[20001];
void midsearch(int t,int a[],int k)
{
int low,high,mid;
low=1;
high=k;
while(low<=high)
{
mid=(low+high)/2;
if(t>a[mid])
low=mid+1;
else if(t<a[mid])
high=mid-1;
else
{
printf("%d\n",1);
return; }
}
printf("%d\n",0);
return;
}
int main()
{
freopen("unlessseq.in","r",stdin);
freopen("unlessseq.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&m[i]);
}
a[1]=1;
k=1;
while(a[k]<100000000)
{ k++;
a[k]=a[k-1]+k-1;
}
for(i=1;i<=n;i++)
midsearch(m[i],a,k); return 0;}