zhaoyutou @ 2024-10-28 19:15:25
using namespace std;
int n,k,a[1003];
bool pfs(int x)
{
int i;
for(i=1;i<=x;i++)
if(i*i==x)
return 1;
return 0;
}
int main()
{
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++)
{
int s=a[i]+a[j];
if(pfs(s))
k++;
}
cout<<k;
return 0;
}```
样例过但不到
只有0分
by zhaoyutou @ 2024-10-28 19:18:27
是不过
by AkihabaraQ @ 2024-11-03 22:46:43
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define int long long
using namespace std;
int n,k,a[1003];
bool pfs(int x)
{
if(x==0) return 1;
int i;
for(i=1;i<=sqrt(x);i++)
{
if(i*i==x) return 1;
}
return 0;
}
signed main()
{
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++)
{
int s=a[i]+a[j];
if(pfs(s))
k++;
}
}
cout<<k;
// return 0;
}
@zhaoyutou
by AkihabaraQ @ 2024-11-03 22:50:31
@zhaoyutou 几点问题
by zhaoyutou @ 2024-11-09 08:27:24
sorry
以关