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 ...
随机推荐
- ruby的在ubuntu上的安装
apt (Debian or Ubuntu) Debian GNU/Linux and Ubuntu use the apt package manager. You can use it like ...
- geotools
http://blog.tigerlihao.cn/2010/01/geotools-based-web-map-service.html
- 在TextView上加上下划线或中划线
在做商城项目是需要用到原价格以及降价后的价格,不可避免用到下划线或中划线 textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下 ...
- LDA-math-文本建模
http://cos.name/2013/03/lda-math-text-modeling/ 4. 文本建模 我们日常生活中总是产生大量的文本,如果每一个文本存储为一篇文档,那每篇文档从人的观察来说 ...
- VC6.0 error LNK2001: unresolved external symbol _main(转)
学习VC++时经常会遇到链接错误LNK2001,该错误非常讨厌,因为对于编程者来说,最好改的错误莫过于编译错误,而一般说来发生连接错误时,编译都已通过.产生连接错误的原因非常多,尤其LNK2001错误 ...
- 表单和验证事件以及marquee标签
1.表单验证<form></form> (1).非空验证(去空格) (2).对比验证(跟一个值对比) (3).范围验证(根据一个范围进行判断) (4).固定格式验证:电话号码, ...
- beta2阶段组员分数分配
小组名称:nice! 小组成员:李权 于淼 刘芳芳 韩媛媛 宫丽君 项目内容:约跑app 分数分配规则 个人贡献分=项目基础分*0.5+个人代码贡献量*0.5 基本贡献分 个人代码贡献量 个人贡献分 ...
- composer 报 zlib_decode(): data error
使用composer 时报 zlib_decode(): data error 错误. 解决办法:执行 composer self-update 即可
- IntelliJ IDEA---java的编译工具【转】
转自:http://baike.baidu.com/link?url=sEpS0rItaB9BiO3i-qCdGSYiTIVPSJfBTjSXXngtN2hBhGl1j36CYQORKrbpqMHqj ...
- Linux下通过crontab及expect实现自动化处理
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] 目标 为实现每天定时从其他服务器上复制文件到本地,需要使用crontab建立定时任务,并通过scp进行Linux之间的文件复制. ...