素数
文章平均质量分 68
azhuge233
Keep ya head up,legs closed,eyes open.
展开
-
HDU 1431 素数回文
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1431此题用无耻法:#include using namespace std;__int64 ans[790]={ 5, 7, 11, 101, 131, 151, 181, 191, 313, 353原创 2016-04-27 16:52:45 · 425 阅读 · 0 评论 -
HDU 4548 美素数
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=4548美素数:本身是素数,并且各位数字的和也是素数打出素数表,再对各位数字求和,访问素数表考察各位和是否为素数详见代码:#include #include #define MAX 1000001using namespace std;bool prime[原创 2016-04-27 17:43:30 · 290 阅读 · 0 评论 -
HDU 2521 反素数
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2521首先,了解一下反素数 :对于任何正整数x,其约数的个数记做g(x).例如g(1)=1,g(6)=4.如果某个正整数x满足:对于任意i(0也就是说,有一个数,它的约数的个数 比 比它小的数的约数个数 都要大,那么 这个数 就是 反素数(若理解有误请指正)但是本题似乎跟反素数没原创 2016-04-27 17:19:19 · 243 阅读 · 0 评论 -
HDU 1262 寻找素数对
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1262#include #include using namespace std;bool is_prime(int n) //素数筛{ for(int i=2; i<=sqrt(n); i++) if(!(n%i)) return 0; return 1;}int原创 2016-04-27 17:04:28 · 218 阅读 · 0 评论 -
HDU 2012 判断素数
链接 :http://acm.hdu.edu.cn/showproblem.php?pid=2012最水的素数题,打表也可以#include #include using namespace std;bool prime(int n){ for(int i=2;i<=sqrt(n);i++) if(!(n%i)) return 0;原创 2016-04-27 18:11:10 · 272 阅读 · 0 评论 -
HDU 2098 分拆素数和
链接 :http://acm.hdu.edu.cn/showproblem.php?pid=2098同2012,加个判断#include #include using namespace std;bool is_prime(int n){ for(int i=2;i<=sqrt(n);i++) if(!(n%i)) return 0;原创 2016-04-27 18:14:02 · 286 阅读 · 0 评论 -
HDU 2136 Largest prime factor
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2136题意:给你一个数n,输出这个数的最大素因子在素数表的位置(或在素数表中找出这个数最大的因子,输出其位置)P.s. cin,cout超时,可能方法本身就不太好吧#include #include #define MAX 1000001using namespace std;原创 2016-04-27 18:29:49 · 241 阅读 · 0 评论 -
HDU 1164 Eddy's research I
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1164题意 : 将任意一个数拆成多个素数相乘的形式(素数可重复)水题,本来想素数表,发现有点脱裤子放屁的意味= =#include using namespace std;int main(){ int n,a[21]; while(cin>>n原创 2016-05-06 21:33:56 · 227 阅读 · 0 评论 -
HDU 1397 Goldbach's Conjecture
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1397题意:哥德巴赫猜想,这次是求 给定偶数 有多少种 素数和,注意同一组数算一次(例如 6=2+3 和 6=3+2 算一个)素数表,循环到n/2即可#include #include using namespace std;bool prime[32770];in原创 2016-05-07 15:23:28 · 496 阅读 · 0 评论