题意:一个H-number是所有的模四余一的数,如 1,5,9,13,17,21...
H-primes数是H-number数(1除外),且它的H-number因子除了1只有它本身,如5,9,13,17,21...
但65是H-number数,却不是H-primes数,因为 65=5*13.
H-semi-prime是H-number数,且等于2个H-primes的乘积.如65
给你一个数n,问1到n有多少个H-semi-prime数
分析:用筛选法的思想,将H-primes筛选出来,同时标记在范围内两个H...
分类:
其他好文 时间:
2014-09-13 17:20:06
阅读次数:
247
记忆化搜索的方式计算f(x)
#include
#include
#include
#include
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
const int maxn = 1000005;
int n;
int primes[maxn],prime_cnt;
int vis[maxn];
int v[maxn];
...
分类:
其他好文 时间:
2014-09-04 19:02:50
阅读次数:
208
1 static void Main(string[] args) 2 { 3 string[] str; 4 bool FLAG; 5 int n = 0, d = 0; 6 List...
分类:
其他好文 时间:
2014-09-01 19:09:13
阅读次数:
222
Problem 35
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13,...
分类:
其他好文 时间:
2014-08-22 17:52:39
阅读次数:
185
Euler discovered the remarkable quadratic formula:
n² + n + 41
It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 = 40...
分类:
其他好文 时间:
2014-08-20 16:21:12
阅读次数:
244
我觉得数学类的题目,每一道都有很好的解决方法,都很有保存的意义和价值。
这道题目里面,巧妙地运用了 唯一分解定理,辅以素数的eratosthenes筛法构造,很好地解决了题目。值得思考和深入的学习。
#include
#include
#include
#include
#include
using namespace std;
vector primes;
const int ma...
分类:
其他好文 时间:
2014-08-11 17:57:02
阅读次数:
158
Difference Between Primes
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
All you know Goldbach conjecture.That is to say, Every even integer greate...
分类:
其他好文 时间:
2014-08-09 18:54:18
阅读次数:
272
http://poj.org/problem?id=3132题意:给定n和k,问用恰好k个不同的质数来表示n的方案数。分析:n和k都很小。反正就是个背包,选k个物品恰好填满n即可。 1 #include 2 #include 3 using namespace std; 4 5 bool dp[1....
分类:
其他好文 时间:
2014-08-05 00:00:58
阅读次数:
300
uva 10168 Summation of Four Primes(数论-哥德巴赫猜想)
题目大意:
给定一个数n,问你是否能用4个质因素相加表示,输出一种方案。
解题思路:
(1)如果n=8,结论是有答案。
因为按照哥德巴赫猜想,一个偶数可以用两个质因素相加表示。
那么,toyking猜想,一个数可以用4个质因素相加表示。
1. n为奇数,可以 用 2+3+偶数表示,偶数可以拆为两个质因素,枚举其中一个即可。
2. n为偶数,可以 用 2+2+偶数表示,偶数可以拆...
分类:
其他好文 时间:
2014-07-31 20:59:17
阅读次数:
191
筛选素数方法小结: 最简单的筛素数法方法就是从2开始,将所以2的倍数去掉,然后从3开始,将3的倍数去掉,依次进行下去即可。根据这样很容易写出代码,下面代码就是是筛素数法得到100以内的素数并保存到primes[]数组中。 1 const int MAXN = 100; 2 bool flag[MA....
分类:
其他好文 时间:
2014-07-31 16:36:37
阅读次数:
223