LS 14 Square free(枚举)
来源:互联网 发布:急用淘宝赚钱 编辑:程序博客网 时间:2024/06/07 09:05
Square free
Test whether
Input
The first line contains an integer
The following
Output
Print "Yes" if
Sample input
21020
Sample output 1
YesNo
思路: 只检查i^3<=n的数,那么最多检查10^6
如果这个数是a*b*b 如果a>n那么b<n所以可以检查
如果a<n 那么就把a剔除检查是否剔除完的数是平方数
这样所有的情况就都包括在内了。
#include<iostream>#include<cstring>#include<cmath>using namespace std;const int mm=1000210;int n;bool p[mm];int f[mm],pos;int main(){ while(cin>>n) { while(n--) { long long m; cin>>m; bool yes=1; long long i; for(i=1;i*i*i<=m&&yes;i++) if(m%i==0) { long long z=m/i; long long y=(long long)sqrt(double(z)+0.01); if(y*y==z)yes=0; m/=i; if(i>1&&m%i==0)yes=0; } if(yes)cout<<"Yes\n"; else cout<<"No\n"; } }}
- LS 14 Square free(枚举)
- BNU - Square-Free Numbers
- SOJ 3191 Free square
- Free from square
- uva 11520 Fill the Square(枚举)
- HDU 6125 Free from square(数论+状压DP)
- uestc 1720 square-free integer(无平方因子数)&nyoj 580square-free integer(容斥,数论)
- 【枚举】Big Square
- HDU 6125 Free from square
- HDU 6125 Free from square
- uva 11520 - Fill the Square(枚举,2级)
- uva 11520 - Fill the Square(贪心+枚举)
- uva 11520 - Fill the Square(贪心+枚举)
- bzoj 1661: [Usaco2006 Nov]Big Square 巨大正方形 (枚举)
- bzoj 1661: [Usaco2006 Nov]Big Square 巨大正方形(枚举)
- hdu 2483 Counting square 枚举
- UVA11520 Fill the Square 枚举
- UVA11520 Fill the Square 枚举
- Openlayers学习笔记——Map类
- IT行业发展之已见
- Openlayers学习笔记——Controls类
- Openlayers学习笔记——Geometry 和 Feature类
- Openlayers学习笔记——Vector Layer 事件类型
- LS 14 Square free(枚举)
- 一键分享文字图片到新浪微博,facebook,twitter 还有保存打印等 (使用 iOS6 自带的 social.framework)
- Openlayers学习笔记——Vector Layer Style
- Openlayers学习笔记——Vector Layer Rules和Filter
- 中介者模式(Mediator)
- 行为模式: Visitor(访问者)
- Openlayers学习笔记——StylingControls
- Geoserver & Openlayers 学习笔记
- Android SAX解析XML文件