請教一下哪裡錯><,一直NA(20%)!!
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
int cmp(const void *a,const void *b){
return *((int*)a)-*((int*)b);
}
int a[3000],n;
bool search(int num){
int i,r=n-1,l=0;
while(r>=l){
i=(l+r)/2;
if(a[i]==num)
return 1;
if(a[i]<num){
l=i+1;
}
else
r=i-1;
}
return 0;
}
int main(){
int i,j,ans;
long long int temp;
while(scanf("%d",&n)!=EOF){
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
ans=0;
qsort(a,n,sizeof(int),cmp);
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
temp=a[j]*a[j]+a[i]*a[i];
if(sqrt(temp)!=(int)sqrt(temp))
continue;
if(search(sqrt(temp))){
ans++;
}
}
}
printf("%d\n",ans);
}
}