摘要: 1 本身不是素数, 因此它没有质因子, 如果题目要求对 1 处理, 要特判; 定义结构体存放质因子及其个数; struct factor { int x, count; // x为质因子, cnt为其个数 }fac[10]; //2*3*5*7*11*13*17*19*23*29就会超过int范围, 阅读全文
posted @ 2018-06-11 20:51 Cirno-9 阅读(621) 评论(0) 推荐(0) 编辑
摘要: The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. 阅读全文
posted @ 2018-06-11 15:52 Cirno-9 阅读(133) 评论(0) 推荐(0) 编辑
摘要: A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a re 阅读全文
posted @ 2018-06-10 21:22 Cirno-9 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 1007 素数对猜想 (20)(20 分) 让我们定义 d~n~ 为:d~n~ = p~n+1~ - p~n~,其中 p~i~ 是第i个素数。显然有 d~1~=1 且对于n&gt1有 d~n~ 是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。 现给定任意正整数N (< 10^5^),请 阅读全文
posted @ 2018-06-10 20:23 Cirno-9 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 筛选代码 阅读全文
posted @ 2018-06-06 22:26 Cirno-9 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 暴力代码 阅读全文
posted @ 2018-06-06 22:25 Cirno-9 阅读(132) 评论(0) 推荐(0) 编辑
摘要: #include const int maxn = 101; int prime[maxn], pNum = 0; bool p[maxn] = { 0 }; void Find_prime() { for (int i = 2; i < maxn; i++) { //注意从2开始, i < maxn结束 if (p[i] == false) { ... 阅读全文
posted @ 2018-06-06 21:16 Cirno-9 阅读(214) 评论(0) 推荐(0) 编辑
摘要: #include #include bool isPrime(int n) { if (n <= 1) return false; int sqr = (int)sqrt(1.0 * n); for (int i = 2; i <= sqr; i++) { //i要从2开始取啊啊啊啊啊啊啊啊 //sqr前要取等号啊啊啊啊啊啊啊 if (n % i =... 阅读全文
posted @ 2018-06-06 20:54 Cirno-9 阅读(174) 评论(0) 推荐(0) 编辑
摘要: #include //素数的判断 bool isPrime(int n) { if (n <= 0) return false; //特判 int sqr = (int)sqrt(1.0 * n); for (int i = 2; i <= sqr; i++) { //遍历2-根号n if (n % i == 0) return Zfalse; ... 阅读全文
posted @ 2018-06-05 23:46 Cirno-9 阅读(181) 评论(0) 推荐(0) 编辑
摘要: For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient. Input Sp 阅读全文
posted @ 2018-06-05 22:55 Cirno-9 阅读(127) 评论(0) 推荐(0) 编辑