csl851231 @ 2024-12-15 18:24:26
#include<bits/stdc++.h>
using namespace std;
int n,m=0,k[1001],sum,o=0;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>k[i];
}
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
sum=k[i]+k[j];
// cout<<sum;
for(int v=1;v<=sum;v++){
if(v*v==sum){
o++;
}
}
}
}
cout<<o;
return 0;
}
by zzgj1235 @ 2024-12-15 18:43:22
我的AC代码
#include<bits/stdc++.h>
using namespace std;
int z(int b){
double c=sqrt(b);
int d=floor(c);
if(d==c){
return 1;
}else{
return 0;
}
}
int a[10005];
int main(){
int n,p=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(z(a[i]+a[j])==1){
p++;
}
}
}
cout<<p;
return 0;
}
by csl851231 @ 2024-12-15 19:28:31
@zzgj1235 已关
by zzgj1235 @ 2024-12-16 20:53:31
@csl851231 已壶关