2015弱校联盟(1) -A. Easy Math
来源:互联网 发布:淮南网络宾馆 编辑:程序博客网 时间:2024/05/16 10:38
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;}
0 0
- 2015弱校联盟(1) -A. Easy Math
- SCU 4436 Easy Math (2015四川省省赛A题)
- [SCU4436] Easy Math [2015 Sichuan Province Contest Final A]
- 2015弱校联盟(1)
- 弱校联盟 2015-10-1 E
- 2015弱校联盟(1) - E. Rectangle
- 2015弱校联盟(1) - I. Travel
- 2015弱校联盟(1) - B. Carries
- 2015弱校联盟(1) - C. Censor
- 2016弱校联盟十一专场10.5---As Easy As Possible(倍增)
- 2015弱校联盟(1) -J. Right turn
- SCU4436-Easy Math
- 2015弱校联盟(2) - J. Usoperanto
- 2015多校联盟
- 联萌十一大决战之强力热身 A. Easy Math
- 弱校联萌十一大决战之强力热身 A. Easy Math (水)
- [math][第二阶段-easy math][HDU-1108]最小公倍数
- [math][第二阶段-easy math][HDU-1722]Cake
- Trie树的java实现
- hdu 5442 Favorite Donut 后缀数组
- 安卓控件使用系列2:TextView实现图文(图片和文字)混排
- 【bzoj4292】 [PA2015]Równanie 乱搞
- 图片爬虫程序 JAVA
- 2015弱校联盟(1) -A. Easy Math
- 黑马程序员-----IO流
- 单链表顺序存储相关操作的c语言实现
- Android:动画效果translate、scale、alpha、rotate详解
- springmvc整合mybatis出现Could not autowire field:No matching bean of type错误
- JAVA实现旋转数组的最小数字问题(《剑指offer》)
- CSS列表
- Windows7 平台下Python+NLTK环境搭建
- Codeforces 492D Vanya and Computer Game