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 ...
随机推荐
- 【Python3的进制扫盲】
一.进制 1.进制简介 进制就是进位制,是人们规定的一种进位方法.计算机底层的数据运算和存储都是二进制数据.计算机语言就是二进制,计算机能直接识别二进制数据,其它数据都不能直接识别. 2.常用进制 对 ...
- Hive(五)hive的高级应用
一.视图 视图:享用基本表的数据,不会生成另外一份数据创建视图:create view view_name as select * from carss;create view carss_view ...
- javascript中的位运算,
罗浮宫群里又有讨论位运算符号|了,做过一段时间php,数据库保存布尔值数据经常用到,比如100110 就表明了六个属性的是与否,极大减少了数据量..] ECMAScript 中位运算跟其他语言一样的. ...
- Winform中的Treeview动态绑定数据库
http://bbs.csdn.net/topics/370139193 SQL code ? 1 2 3 4 5 6 CREATE TABLE [dbo].[Company] ( [Id ...
- Spring MVC入门示例
1.新建一个Java Web项目 2.导入jar包 3.在WEB-INF下面建一个hello.jsp页面. <%@ page language="java" import=& ...
- Netfilter之连接跟踪实现机制初步分析
Netfilter之连接跟踪实现机制初步分析 原文: http://blog.chinaunix.net/uid-22227409-id-2656910.html 什么是连接跟踪 连接跟踪(CONNT ...
- 协程-遇到I/O自动切换
参考博客:http://www.cnblogs.com/alex3714/articles/5248247.html 一.前言 Gevent 是一个第三方库,可以轻松通过gevent实现并发同步或异步 ...
- [吴恩达机器学习笔记]11机器学习系统设计3-4/查全率/查准率/F1分数
11. 机器学习系统的设计 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考资料 斯坦福大学 2014 机器学习教程中文笔记 by 黄海广 11.3 偏斜类的误差度量 Error Metr ...
- selenium利用Excel进行参数化(简单示例)
上篇搭建好环境后,正真开始我的自动化之旅了.... 开始之前特别说明一下testNG的版本,不能直接使用Eclipse直接线上下载的版本,线上版本太高,不能兼容,运行程序会报以下错误,需要自行下载低一 ...
- 树上的构造 树分治+树重心的性质 Codeforces Round #190 (Div. 2) E
http://codeforces.com/contest/322/problem/E E. Ciel the Commander time limit per test 1 second memor ...