CSU 1416 Practical Number
原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1416
结论题,具体判断方法请点击这个网址。
筛素数是肯定的,但一开始定的范围太大了,想当然要筛到10^9的质数,但仔细想想,只要到sqrt(10^9)就可以了,最后的那一个质数是最后一步的比较,不用筛出来。
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std; #define N 100005 typedef long long LL; bool vis[N];
int p[N], k=; void get_prime()
{
for(int i = ; i < N; i++)
{
if(!vis[i])
{
p[k++] = i;
for(int j = i + i; j < N; j += i)
vis[j] = ;
}
}
} bool ok(LL n)
{
if(n == ) return ;
if(n&) return ;
LL al = ;
for(int i = ; i < k; i++)
{
if(n % p[i] == )
{
if(p[i] > al + && p[i] != ) return ;
LL s = ;
LL tmp = ;
while(n%p[i] == )
{
n /= p[i];
tmp *= p[i];
s += tmp;
}
al *= s;
}
}
if(n > al + ) return ;
return ;
} int main()
{
int t; LL n;
get_prime();
cin >> t;
while(t--)
{
cin >> n;
if(ok(n)) cout << "Yes" << endl;
else cout << "No" << endl;
}
return ;
}
CSU 1416 Practical Number的更多相关文章
- Erlang 转至维基百科
Erlang(英语发音:/ˈɜrlæŋ/)是一种通用的并行程序设计语言,它由乔·阿姆斯特朗(Joe Armstrong)在瑞典电信设备制造商爱立信所辖的计算机科学研究室开发,目的是创造一种可以应付大规 ...
- csuoj 1392: Number Trick
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1392 1392: Number Trick Time Limit: 1 Sec Memory L ...
- 搜索+剪枝 POJ 1416 Shredding Company
POJ 1416 Shredding Company Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5231 Accep ...
- Practical Machine Learning For The Uninitiated
Practical Machine Learning For The Uninitiated Last fall when I took on ShippingEasy's machine learn ...
- URAL 1416 Confidential(次小生成树)
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1416 Zaphod Beeblebrox — President of the Impe ...
- csu 1305 Substring (后缀数组)
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1305 1305: Substring Time Limit: 2 Sec Memory Limi ...
- CSU 1616: Heaps(区间DP)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1616 1616: Heaps Time Limit: 2 Sec Memory Lim ...
- Learn LIBSVM---a practical Guide to SVM classification
想学习一下SVM,所以找到了LIBSVM--A Library for Support Vector Machines,首先阅读了一下网站提供的A practical guide to SVM cla ...
- Practical Web Penettation Testing (the first one Mutillidae 大黄蜂)
1.now we looke at this book . I decide to make a brief review the book covers as follows (I straigh ...
随机推荐
- 【loj6179】Pyh的求和
Portal -->loj6179 Solution 这题其实有一个式子一喵一样的版本在bzoj,但是那题是\(m\)特别大然后只有一组数据 这题多组数据== 首先根据\(\v ...
- Winform中的Treeview动态绑定数据库
http://bbs.csdn.net/topics/370139193 SQL code ? 1 2 3 4 5 6 CREATE TABLE [dbo].[Company] ( [Id ...
- phpstorm 自定义属性没语法提示的问题
在右侧Options勾选上Custom HTML tag attributes,并且在下面的输入框输入自定义属性列表,逗号分隔.
- linux根据进程pid查看进程详细信息
http://note.youdao.com/noteshare?id=af2fdd34e3adfacda2d34706e16e5045
- duilib 修复CTreeViewUI控件动态添加子控件时,对是否显示判断不足的bug
转载请说明出处,谢谢~~:http://blog.csdn.net/zhuhongshu/article/details/42264947 这个bug我在仿酷狗开发日志里提到过,不过后来发现修复的不够 ...
- DINSTINCT
DISTINCT是对结果集进行去重,有三点需要注意. 1.在大多数情况下(两者后面所跟的字段相同时),DISTINCT跟group by是等效的,此时DISTINCT可以看作group by的一个特例 ...
- java中16进制转换10进制
java中16进制转换10进制 public static void main(String[] args) { String str = "04e1"; String myStr ...
- git入门篇shell
什么是shell 在计算机科学中,Shell俗称壳,用来区别于Kernel(核),是指“提供使用者使用界面”的软件(命令解析器),它类似于windows系统下的cmd.exe, 它接收用户命令,然后调 ...
- CSS3的新属性
1.圆角矩形 .border_radius_test{ border-radius:25px; -moz-border-radius:25px; } 数值越大越圆 2.容器阴影 .box_shadow ...
- .Net各版本新特性
序言 C# 1.0 (2002) public interface IDateProvider { DateTime GetDate(); } 隐式接口实现 public class DefaultD ...