Problem Description
WhereIsHeroFrom: Zty, what are you doing ?
Zty: I want to calculate N!......
WhereIsHeroFrom: So easy! How big N is ?
Zty: 1 <=N <=1000000000...
分类:
其他好文 时间:
2015-03-13 16:41:44
阅读次数:
100
Problem Description
Write a program to read in a list of integers and determine whether or not each number is prime. A number, n, is prime if its only divisors are 1 and n. For this problem, the numbers 1 and 2 are not considered primes.
Input
Each inp...
分类:
其他好文 时间:
2015-03-13 14:24:56
阅读次数:
130
局部静态对象: 某些时候,有必要令局部变量的生命周期贯穿函数调用及之后的时间。可以将局部变量定义成static类型从而获得这样的对象。局部静态对象在程序执行路径第一次经过对象定义语句时初始化,并且直到程序终止才被销毁,在此期间即使对象所在的函数结束执行也不会对它有影响。size_t count...
分类:
编程语言 时间:
2015-03-13 07:02:08
阅读次数:
329
判断一个数是不是素数: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
定义一个字典let interestingNumber =[ "Prime":[2,3,5,7,11,13], "Fibonacci":[1,1,2,3,5,8], "Square":[1,4,9,16,25]]var array = interestingNumber["Pri...
分类:
编程语言 时间:
2015-03-12 22:28:09
阅读次数:
147
根据维基百科定义,质数(Prime number),又称素数,指在大于1的自然数中,除了1和此整数自身外,无法被其他自然数整除的数(也可定义为只有1和本身两个因数的数)。比1大但不是素数的数称为合数。1和0既非素数也非合数。质数在公钥加密算法(如RSA)中有重要的地位。 下边将会介绍几种较为常...
分类:
其他好文 时间:
2015-03-12 22:17:57
阅读次数:
217
欧几里得求公约数:int gcd(int a, int b){ while (b) { int tmp = b; b = a % b; a = tmp; } return a;}筛选法求素数:int prime(){ memse...
分类:
其他好文 时间:
2015-03-12 18:32:57
阅读次数:
99
Problem Description
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.
Now given a humble number, please w...
分类:
其他好文 时间:
2015-03-12 17:17:24
阅读次数:
128
sizeof运算符的结果部分地依赖于其作用的类型: 对char或者类型为char的表达式执行sizeof运算结果得1; 对引用类型执行sizeof运算得到被引用对象所占空间的大小; 对指针执行sizeof运算得到指针本身所占空间的大小; 对解引用指针执行sizeof运算得到指针指向的对象所占...
分类:
编程语言 时间:
2015-03-12 06:22:07
阅读次数:
143
C++11新标准引入了一种更简单的for语句,这种语句可以遍历容器或者其他序列的所有元素。范围for语句的语法形式是: for( declaration : expression) statement expression表示的必须是一个序列,序列中的每个元素都能转换成该变量的类型。确...
分类:
编程语言 时间:
2015-03-12 06:19:35
阅读次数:
144