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 3Sample 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;
}
博客围绕Easy Math问题,给定n个整数,需判断它们平方根之和是否为整数。介绍了输入格式,包含多组测试,每组先给出整数n,再给出n个整数;输出根据和是否为整数给出相应结果,并给出了示例输入和输出。

被折叠的 条评论
为什么被折叠?



