A. Easy Math

Time Limit: 2000ms

Memory Limit: 65536KB

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 <bits/stdc++.h>
#define LL long long
#define fread() freopen("in.in","r",stdin)
#define fwrite() freopen("out.out","w",stdout) using namespace std; int main()
{
int n,data;
while(~scanf("%d",&n))
{
bool flag=false;
while(n--)
{
scanf("%d",&data);
if(flag)
{
continue;
}
int ans=(int)sqrt(data);
if(ans*ans!=data)//判断是不是平方数
{
flag=true;
}
}
if(flag)
{
cout<<"No"<<endl;
}
else
{
cout<<"Yes"<<endl;
}
}
return 0;
}

2015弱校联盟(1) -A. Easy Math的更多相关文章

  1. 2015弱校联盟(2) - J. Usoperanto

    J. Usoperanto Time Limit: 8000ms Memory Limit: 256000KB Usoperanto is an artificial spoken language ...

  2. 2015弱校联盟(1) - C. Censor

    C. Censor Time Limit: 2000ms Memory Limit: 65536KB frog is now a editor to censor so-called sensitiv ...

  3. 2015弱校联盟(1) - B. Carries

    B. Carries Time Limit: 1000ms Memory Limit: 65536KB frog has n integers a1,a2,-,an, and she wants to ...

  4. 2015弱校联盟(1) - I. Travel

    I. Travel Time Limit: 3000ms Memory Limit: 65536KB The country frog lives in has n towns which are c ...

  5. 2015弱校联盟(1) -J. Right turn

    J. Right turn Time Limit: 1000ms Memory Limit: 65536KB frog is trapped in a maze. The maze is infini ...

  6. 2015弱校联盟(1) - E. Rectangle

    E. Rectangle Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld Java class name ...

  7. 2016弱校联盟十一专场10.5---As Easy As Possible(倍增)

    题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8506#problem/A problem description As we know, t ...

  8. (2016弱校联盟十一专场10.5) F. Fibonacci of Fibonacci

    题目链接 题目大意就是这个,先找出下标的循环节,再快速幂对20160519取余就行了. 找出下标循环节: #include <cstdio> #include <iostream&g ...

  9. (2016弱校联盟十一专场10.3) D Parentheses

    题目链接 把左括号看成A右括号看成B,推一下就行了.好久之前写的,推到最后发现是一个有规律的序列. #include <bits/stdc++.h> using namespace std ...

随机推荐

  1. SQL server while语句、存储过程

    1.循环语句 2.存储过程 存储过程(stored procedure)有时也称为sproc.存储过程存储于数据库中而不是在单独的文件中,有输入参数.输出参数以及返回值等. 3.四种存储过程类型(类似 ...

  2. CentOs5.8下安装Oracle12C

    12C安装向导: http://docs.oracle.com/database/121/LTDQI/toc.htm 12C下载地址: http://www.oracle.com/technetwor ...

  3. jquery ui bootstrap日期插件

    http://blog.csdn.net/php_897721669/article/details/7404527 搜索“jquery ui日期插件怎么显示年份”? $("#datepic ...

  4. window svn backup.bat

    help command /? call /? %cd% 可以用在批处理文件中,也可以用在命令行中:展开后,是驱动器盘符:+当前目录,如在dos窗口中进入c:\dir目录下面, %0代指批处理文件自身 ...

  5. Ubuntu下编译第一个C程序的成功运行

    1. 打开控制台:使用快捷键 Ctrl + Alt + T: 2.  安装gcc为C语言编译器,g++为C++ 语言编译器 sudo apt-get install g++. 3.  编辑好hello ...

  6. php课程---语句及函数

    语句:    一:分支语句        1.if(条件1){满足条件1执行}    2.if(条件1){满足条件1执行}else{不满足条件1执行}    3.if(条件1){满足条件1执行}els ...

  7. Choose Concurrency-Friendly Data Structures

    What is a high-performance data structure? To answer that question, we're used to applying normal co ...

  8. web.xml配置error-page

    一. 通过错误码来配置error-page <error-page> <error-code>404</error-code> <location>/e ...

  9. Flink - state管理

    在Flink – Checkpoint 没有描述了整个checkpoint的流程,但是对于如何生成snapshot和恢复snapshot的过程,并没有详细描述,这里补充   StreamOperato ...

  10. Android如何通过shareduserid获取系统权限

    [原文] android会为每个apk进程分配一个单独的空间(比如只能访问/data/data/自己包名下面的文件),一般情况下apk之间是禁止相互访问数据的.通过Shared User id,拥有同 ...