- 博客(3)
- 收藏
- 关注
原创 判断一个数是质数的几种方法
质数也叫素数,是只能被1和它本身整除的正整数,最小的质数是2,目前发现的最大的质数是p=2^57885161-1【注1】。 判断一个数是质数的最简单的方法如下: [code="Python"] def isPrime1(n): for i in range(2, n): if n % i == 0: return False return True [/code] ...
2013-05-17 16:28:42 563
原创 POJ1276
[code="c++"] #include using namespace std; int main() { int cash,n,max; while(cin>>cash>>n) { max = 0; int m[1001],v[1001]; for(int i = 0;i>m[i]>>v[i]; bool dp[100001]; me...
2013-05-16 12:10:21 111
原创 Project Euler 23:Find the sum of all the positive integers which cannot be writt
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means th...
2013-05-16 12:08:13 193
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人