题意:输入正整数n,把整数1,2,3,……,n组成一个环,使得相邻的两个整数之和均为素数。输出时从整数1 开始逆时针排列。同一个环应恰好输出一次。n 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int is_prime(i....
分类:
其他好文 时间:
2015-08-02 16:42:12
阅读次数:
105
题目:求1到1亿间的质数或素数思路:什么是质数?质数(prime number)又称素数,有无限个。一个大于1的自然数,除了1和它本身外,不能被其他自然数(质数)整除,换句话说就是该数除了1和它本身以外不再有其他的因数;否则称为合数。(来自百度百科)方法1:遍历1到1亿间的所有数,然后逐个判断是否为...
分类:
编程语言 时间:
2015-08-02 13:12:21
阅读次数:
191
给出2个四位数的素数a,b,要求a每次变化只可以变a的4个数字的其中一个,并且变化后的数也要是素数,问a至少要变化多少次才可以变为b。注意,a的千位数不能变化为0先打出素数表,再bfs数a即可。 1 #include 2 #include 3 #include 4 5 using namespac....
分类:
其他好文 时间:
2015-08-01 21:54:15
阅读次数:
94
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1075
思路:分解素因子#include
#include
#include
using namespace std;
const int maxn=65535+5;
typedef long long LL;
bool prime[maxn];
in...
分类:
其他好文 时间:
2015-08-01 15:46:21
阅读次数:
112
有一定的结论需要知道、、、 1 #include 2 #include 3 #include 4 using namespace std; 5 typedef long long LL; 6 LL ans,ans1,n,prime[8] = {2,3,5,7,11,13,17,19}; 7 v...
分类:
其他好文 时间:
2015-08-01 06:23:04
阅读次数:
121
Prime Ring ProblemProblem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circl...
分类:
其他好文 时间:
2015-07-31 20:10:45
阅读次数:
186
#include
#include
#include Kint tmp[1000], cnt, rec[1000];
int prime[30] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 39, 41, 43, 47};
double ans, LOG[30];void DFS(int...
分类:
其他好文 时间:
2015-07-30 23:17:25
阅读次数:
251
求 ∑ gcd(x, y) = p ( p 是质数, 1 using namespace std;typedef long long ll;const int maxn = 10000009;bool check[maxn];int prime[maxn], N = 0, mu[maxn], f[m...
分类:
其他好文 时间:
2015-07-30 23:01:46
阅读次数:
129
Pandigital prime
Problem 41
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
What...
分类:
其他好文 时间:
2015-07-30 17:05:09
阅读次数:
154
Truncatable primes
Problem 37
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 7...
分类:
其他好文 时间:
2015-07-30 13:43:24
阅读次数:
148