判断一个数是不是素数:bool prime(int n){ if(n==0||n==1) return false; if(n==2) return true; for(int i=2;i<=sqrt(n);i++) if(n%i==0) ret...
分类:
其他好文 时间:
2015-03-12 23:49:14
阅读次数:
161
Drazil is playing a math game with Varda.
Let’s define for positive integer x as a product of factorials of its digits. For example, .
First, they choose a decimal number a consisting of n digits that contain...
分类:
其他好文 时间:
2015-02-18 06:13:14
阅读次数:
172
POJ 2262 Goldbach's Conjecture(素数相关)http://poj.org/problem?id=2262题意: 给你一个[6,1000000]范围内的偶数,要你将它表示成两个素数相加和的形式。假设存在多组解,请输出两个素数差值最大的解。分析: 首先我们用素数筛选法求出10...
分类:
数据库 时间:
2015-02-14 19:58:30
阅读次数:
165
Calling Extraterrestrial Intelligence Again
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4637 Accepted Submission(s): 2433
Probl...
分类:
其他好文 时间:
2015-02-12 09:23:09
阅读次数:
194
POJ 2262 Goldbach's Conjecture(素数相关)
http://poj.org/problem?id=2262
题意:
给你一个[6,1000000]范围内的偶数,要你将它表示成两个素数相加和的形式。如果存在多组解,请输出两个素数差值最大的解。
分析:
首先我们用素数筛选法求出100W以内的所有素数。
筛选法求素数可见:
http://blog.csdn.net/u013480600/article/details/411200...
分类:
数据库 时间:
2014-11-15 11:27:48
阅读次数:
254
弱菜开始学数论了,不定时更新。。。一.素数定理: 素数分布:小于x的素数大约有 x/ln(x)个 推论:如果Pn为第n个素数 那个Pn约等于n*ln(n);二.素数测试 1.sqrt(n)的朴素测试。这个就不多说了,数据范围小的时候比较方便 2.nlogn的筛法void setprime()...
分类:
其他好文 时间:
2014-09-09 11:51:38
阅读次数:
220
掌握了容斥原理后,便会发现,这是一道简单的容斥原理的题。
题目描述:给定A, B, N (1 <= A <= B <= 10^15,1<=N <= 10^9).求[A,B]区间内与N互素的数的个数
看到这道题,自然联想到跟素数相关的知识,所以在做这道题之前,我忍不住整理一下关于素数的基本算法。
1、素数筛选法(求1~n的素数):http://blog.csdn.net/yzj577/article/details/38147433
2、验证素数:http://blog.c...
分类:
其他好文 时间:
2014-07-27 11:27:22
阅读次数:
291