A
Given n integers a1,a2,…,an , check if the sum of their square root a1−−√+a2−−√+⋯+an−−√ is a integer.
Input
The input consists of multiple tests. For each test:
The first line contains
1
integer
n
(
1≤n≤105
).
The second line contains
n
integers
a1,a2,…,an
(
0≤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 <iostream>
#include <cmath>
using namespace std;
int main()
{
int n;
while(cin>>n&&n)
{
bool flag=true;
for(int i=0;i<n;++i)
{
double tmp;
cin>>tmp;
if(sqrt(tmp)!=int(sqrt(tmp)))
{
//cout<<sqrt(tmp)<<endl;
//cout<<int(sqrt(tmp))<<endl;
flag=false;
}
}
if(flag)
cout<<"Yes\n";
else
cout<<"No\n";
}
return 0;
}