hdu 3826
Squarefree number
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1984 Accepted Submission(s):
526
divisible by no perfect squares, except 1. For example, 10 is square-free but 18
is not, as it is divisible by 9 = 3^2. Now you need to determine whether an
integer is squarefree or not.
number of test cases.
For each test case, there is a single line contains an
integer N.
Technical Specification
1. 1 <= T <= 20
2. 2
<= N <= 10^18
output "Yes" if N is squarefree, "No" otherwise.
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<math.h>
using namespace std;
typedef __int64 LL; bool s[];
LL prime[],len;
void init()
{
int i,j;
len=;
memset(s,false,sizeof(s));
for(i=;i<=;i++)
{
if(s[i]==true)continue;
prime[++len]=i;
for(j=i*;j<=;j=j+i)
s[j]=true;
}
}
LL Euler(LL n)
{
LL i,num;
for(i=;prime[i]*prime[i]<=n && i<=len;i++)
{
if(n%prime[i]==)
{
num=;
while(n%prime[i]==)
{
n=n/prime[i];
num++;
if(num>=) return ;
}
}
}
return n;
}
int main()
{
init();
int T,t;
LL n;
scanf("%d",&T);
for(t=;t<=T;t++)
{
scanf("%I64d",&n);
LL ans = Euler(n);
if(ans==)
{
printf("Case %d: No\n",t);
}
else
{
LL cur=(LL)sqrt(ans*1.0);
if(cur*cur==ans)printf("Case %d: No\n",t);
else printf("Case %d: Yes\n",t);
}
}
return ;
}
hdu 3826的更多相关文章
- HDU 3826 Squarefree number ( 唯一分解定理 )
题目链接 题意 : 给出一个数.问其能不能被任何一个平方数整除.如果可以则输出 No 即不是 Square-free Number .否则输出 Yes 分析 : 首先 N 有 1e18 那么大.不能暴 ...
- hdu 1573 X问题 (非互质的中国剩余定理)
X问题 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
随机推荐
- codevs 1202 求和
http://codevs.cn/problem/1202/ 1202 求和 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 青铜 Bronze 题解 题目描述 D ...
- C# eval()函数浅谈
<%# Bind("Subject") %> //绑定字段 <%# Container.DataItemIndex + 1%> //实现自动编号<%# ...
- 手动写的第一个eChart代码
手动写的第一个eChart代码 ,第一感觉,杂乱无章 <!doctype html> <html> <head> <meta charset="UT ...
- paper 62:高斯混合模型(GMM)参数优化及实现
高斯混合模型(GMM)参数优化及实现 (< xmlnamespace prefix ="st1" ns ="urn:schemas-microsoft-com:of ...
- paper 1:图像特征提取
特征提取是计算机视觉和图像处理中的一个概念.它指的是使用计算机提取图像信息,决定每个图像的点是否属于一个图像特征.特征提取的结果是把图像上的点分为不同的子集,这些子集往往属于孤立的点.连续的曲线或者连 ...
- sql查询 所有被锁定的表
--sql查询 所有被锁定的表 select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName ...
- 夺命雷公狗---TP商城----TP之配置环境---1
下载到tp3.2.3版本后架设到自己的wamp环境下,然后配置虚拟主机,完事后直接开工 环境下创建一个文件夹,然后里面存放这这两个文件即可开始新的旅途了 这里完了,下一步就开始配置index.php文 ...
- 给debian安装xfce桌面套装
首先要有一个debian的基本系统,然后: 1.sudo apt-get install xorg slim xfce4 #xdm 由于目前源里面最新的版本是4.3.99,想安装4.4 ...
- 【crunch bang】调整窗口大小
在终端下, <super> + 上箭头 == 向上调整大小 <super> + 下箭头(左.右)
- VS中快速生成json数据格式对应的实体
JSON是一种取代XML的数据结构,和xml相比,它更小巧但描述能力却不差,由于它的小巧所以网络传输数据将减少更多流量从而加快速度. JSON就是一串字符串 只不过元素会使用特定的符号标注. {} 双 ...