I_AM_BIG_SB_ @ 2024-10-24 14:08:28
#include<bits/stdc++.h>
using namespace std;
long long a,b[1010],ans;
int main(){
cin>>a;
for(int i=1;i<=a;i++){
cin>>b[i];
}
for(int i=1;i<=a-1;i++){
for(int j=i+1;j<=a;j++)
if(sqrt(b[i]+b[j])*sqrt(b[i]+b[j])==b[i]+b[j])
ans++;
}
cout<<ans;
}
by I_AM_BIG_SB_ @ 2024-10-24 14:14:53
这是我的结果
by AkihabaraQ @ 2024-11-03 22:35:22
#include<bits/stdc++.h>
using namespace std;
long long a,b[1010],ans;
int main(){
cin>>a;
for(int i=1;i<=a;i++){
cin>>b[i];
}
for(int i=1;i<=a-1;i++){
for(int j=i+1;j<=a;j++)
if(sqrt(b[i]+b[j])==(int)sqrt(b[i]+b[j]))
ans++;
}
cout<<ans;
}
@I_AM_BIGSB
by AkihabaraQ @ 2024-11-03 22:36:16
@I_AM_BIGSB 改一下判定方式,之前那个在类型自动转换的时候可能会出错
by AkihabaraQ @ 2024-11-03 22:36:36
求关谢谢
by I_AM_BIG_SB_ @ 2024-11-10 08:11:07
@AkihabaraQ
100分了,谢谢大神,已关注