原题链接: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的更多相关文章

  1. Erlang 转至维基百科

    Erlang(英语发音:/ˈɜrlæŋ/)是一种通用的并行程序设计语言,它由乔·阿姆斯特朗(Joe Armstrong)在瑞典电信设备制造商爱立信所辖的计算机科学研究室开发,目的是创造一种可以应付大规 ...

  2. csuoj 1392: Number Trick

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1392 1392: Number Trick Time Limit: 1 Sec  Memory L ...

  3. 搜索+剪枝 POJ 1416 Shredding Company

    POJ 1416 Shredding Company Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5231   Accep ...

  4. Practical Machine Learning For The Uninitiated

    Practical Machine Learning For The Uninitiated Last fall when I took on ShippingEasy's machine learn ...

  5. URAL 1416 Confidential(次小生成树)

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1416 Zaphod Beeblebrox — President of the Impe ...

  6. csu 1305 Substring (后缀数组)

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1305 1305: Substring Time Limit: 2 Sec  Memory Limi ...

  7. CSU 1616: Heaps(区间DP)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1616 1616: Heaps Time Limit: 2 Sec  Memory Lim ...

  8. Learn LIBSVM---a practical Guide to SVM classification

    想学习一下SVM,所以找到了LIBSVM--A Library for Support Vector Machines,首先阅读了一下网站提供的A practical guide to SVM cla ...

  9. 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 ...

随机推荐

  1. POJ.3468 A Simple Problem with Integers(线段树 区间更新 区间查询)

    POJ.3468 A Simple Problem with Integers(线段树 区间更新 区间查询) 题意分析 注意一下懒惰标记,数据部分和更新时的数字都要是long long ,别的没什么大 ...

  2. 自动化测试常用断言的使用方法(python)

    自动化测试中寻找元素并进行操作,如果在元素好找的情况下,相信大家都可以较熟练地编写用例脚本了,但光进行操作可能还不够,有时候也需要对预期结果进行判断. 这里介绍几个常用断言的使用方法,可以一定程度上帮 ...

  3. Linux之系统信息操作20170330

    介绍一下Linux系统中一些自带信息的获取操作等,首先从源码中找到系统信息结构体进行分析. 1.系统信息结构体说明与获取方法: 含义: struct sysinfo { long uptime;    ...

  4. Codeforces 221 D. Little Elephant and Array

    D. Little Elephant and Array time limit per test 4 seconds memory limit per test 256 megabytes input ...

  5. 2-sat 分类讨论 UVALIVE 3713

    蓝书326 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits/stdc++.h> using namespace std; ...

  6. 2017 ACM Arabella Collegiate Programming Contest(solved 11/13)

    省选考前单挑做点ACM练练细节还是很不错的嘛- 福利:http://codeforces.com/gym/101350 先来放上惨不忍睹的virtual participate成绩(中间跑去食堂吃饭于 ...

  7. Mysql通过show processlist排查数据库执行慢

    RDS for MySQL使用的是InnoDB引擎.不同于MyISAM引擎只提供表锁,InnoDB提供不同级别的锁.但是在我们日常的操作过程中经常由于对数据库不当的SQL操作导致出现长时间的锁,造成其 ...

  8. bluebird -1 New Promise方法

    new Promise new Promise(function(function resolve, function reject) resolver) -> Promise 创建一个Prom ...

  9. 解决gridview row 左边序列号 显示不完全的技巧

    放在主程序 入口处, public Form1() { InitializeComponent(); gridView1.IndicatorWidth = ; //<宽度值>官方推荐常用是 ...

  10. [bzoj 2460]线性基+贪心+证明过程

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2460 网上很多题目都没说这个题目的证明,只说了贪心策略,我比较愚钝,在大神眼里的显然的策略 ...