原题链接: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. 代码收藏系列--php--加载sql文件并解析成数组

    php加载sql文件,解析成以分号分割的数组.(支持存储过程和函数提取,自动过滤注释) /** * 加载sql文件为分号分割的数组 * <br />支持存储过程和函数提取,自动过滤注释 * ...

  2. [IOI2013]Dreaming

    link 一道非常类似的题目(link) 试题大意 给你一棵含有$n$个节点的有边权森林,问每次连边将会用$L$的代价,问你若此图通过加边成为树时的最小直径.$n \leq 5\times 10^5$ ...

  3. HBuilder mui登录和访问控制教程--转载

    HBuilder mui登录和访问控制教程 mui中提供了登录的模板页,但是对于登录后各个页面的访问控制,刷新等并没有官方的推荐方案.我在这里简单说一种初级的解决方案吧,肯定有不足指出,欢迎批评指正. ...

  4. 前端PHP入门-025-数组-重中之重

    数组是PHP中一个 很很很很很很很很很很重要 的一个 数据类型 . 学习数组,大家主要学习两部份的知识: 1.数组的定义,定义中的一些注意的坑 2.数组的函数使用 认识数组 数组定义 数组在之前我们让 ...

  5. 基础但是很重要的2-sat POJ 3678

    http://poj.org/problem?id=3678 题目大意:就是给你n个点,m条边,每个点都可以取值为0或者1,边上都会有一个符号op(op=xor or and三种)和一个权值c.然后问 ...

  6. JAVA多线程提高十三:同步集合类的应用

    1.引言 在多线程的环境中,如果想要使用容器类,就需要注意所使用的容器类是否是线程安全的.在最早开始,人们一般都在使用同步容器(Vector,HashTable),其基本的原理,就是针对容器的每一个操 ...

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

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

  8. Oracle Number类型超长小数位为0问题

    碰到了一个非常奇怪的问题,从Excel拷贝出来的数据,位数很长,通过Pl Sql 导出到Oracle后为0了,而且设置查询条件为0时,无法查询出来,条件大于0居然能查询出来,通过to_number也是 ...

  9. 【BZOJ4870】组合数问题(计数DP,快速幂)

    题意: 1 ≤ n ≤ 10^9, 0 ≤ r < k ≤ 50, 2 ≤ p ≤ 2^30 − 1 思路:From http://blog.csdn.net/qq_33229466/artic ...

  10. java对象与json互转

    package com.liveyc; import java.io.StringWriter; import org.junit.Test; import com.fasterxml.jackson ...