Easy Math
Given nn integers a1,a2,…,ana1,a2,…,an, check if the sum of their square root a1−−√+a2−−√+⋯+an−−√a1+a2+⋯+an is a integer.
Input
The input consists of multiple tests. For each test:
The first line contains 11 integer nn (1≤n≤1051≤n≤105). The second line contains nnintegers a1,a2,…,ana1,a2,…,an (0≤ai≤1090≤ai≤109).
Output
For each test, write "Yes
" if the sum is a integer, or "No
" otherwise.
Sample Input
2
1 4
2
2 3
Sample Output
Yes
No
#include <bits/stdc++.h>
using namespace std;
map<long long,bool>m; //map
int main()
{
for(int i=0;i<=100000;i++)
m[i*i]=1; //标记存在
int n;while(~scanf("%d",&n))
{
bool flag=1;
while(n--)
{
int c;scanf("%d",&c);
if(!m[c]&&flag)
{
printf("No\n");
flag=0;
}
}
if(!flag) continue;
printf("Yes\n");
}
return 0;
}