自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(26)
  • 收藏
  • 关注

用clojure解决euler problem 12

问题描述:The sequence of triangle numbers is generated by adding the natural numbers. So the 7thtriangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:1, 3, 6, 10, 1...

2012-07-13 21:00:00 104

用clojure解决 euler problem 11

问题描述:In the 2020 grid below, four numbers along a diagonal line have been marked in red.08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 0849 49 99 40 17 81 18 57 60 87 17 40 98 43 6...

2012-07-12 10:16:00 123

用clojure解决euler problem 10

问题描述:The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes below two million.解决方案:(ns euler-problem-10.core (:use [clojure.contrib.math]))(defn prime? [n...

2012-07-09 21:01:00 132

用clojure解决euler problem 9

问题描述:A Pythagorean triplet is a set of three natural numbers,abc, for which,a2+b2=c2For example, 32+ 42= 9 + 16 = 25 = 52.There exists exactly one Pythagorean triplet for whicha+b+c= ...

2012-07-08 22:25:00 82

用clojure解决euler problem 8

问题描述:Find the greatest product of five consecutive digits in the 1000-digit number.73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156...

2012-07-08 21:06:00 115

用clojure解决euler problem 7

问题描述:By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10 001st prime number?解决方案:(ns euler-problem-7.core (:use [clojure.con...

2012-07-08 20:39:00 73

用clojure解决 euler problem 6

问题描述:The sum of the squares of the first ten natural numbers is,12+ 22+ ... + 102= 385The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2= 552= 3025Hence the ...

2012-07-08 13:37:00 72

用clojure解决euler problem 5

问题描述:2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that isevenly divisibleby all of the numbers...

2012-07-08 10:43:00 96

用clojure解决 euler problem 4

问题描述:A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is9009 = 9199.Find the largest palindrome made from the product of two...

2012-07-07 21:12:00 105

用clojure解决euler problem 3

问题描述:The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?(ns euler-problem-3.core)(defn largest-prime-factor [number] (loop ...

2012-07-06 20:47:00 97

用clojure解决 euler problem 2

问题描述:Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By cons...

2012-07-06 12:47:00 48

用clojure解决 euler problem 1

问题描述:If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.解决方案1...

2012-07-05 22:10:00 98

sicp练习 1.22

(define (square x) (* x x))(define (smallest-divisor n) (find-divisor n 2))(define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-d...

2011-05-27 22:33:51 149

原创 sicp练习1.21用smallest-divisor寻找最小因子

(define (square x) (* x x))(define (smallest-divisor n) (find-divisor n 2))(define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-d...

2011-05-22 14:36:43 176

原创 sicp练习1.20 gcd过程 应用序 正则序 remainder次数

(define (gcd a b remainder-count) (if(= b 0) (begin (display "\nremainder count: ") (display remainder-count) (display "\n gcd result:") (display ...

2011-05-17 09:41:04 188

原创 sicp练习1.18 基于加法、加倍和折半运算求两个整数之乘积

;double的功能是2*n(define (double n) (+ n n))(double 5);havle-iter函数的功能是通过迭代获得n的一半的值,guess是初始猜测值(define (havle-iter guess n) (cond ((not (integer? n)) (display "error: 原因havle函数的参数是整数...

2011-05-13 23:32:27 172

sicp练习1.17 只有加减法 实现快速求幂

;double的功能是2*n(define (double n) (+ n n))(double 5);*函数的功能是a乘以b(define (* a b) (if (= b 0) 0 (+ a (* a (- b 1)))))(* 3 4);havle-iter函数的功能是通过迭代获得n的一半的值,guess是...

2011-05-13 20:37:52 146

原创 快速求幂 sicp练习1.16

(define (even? n) (= (remainder n 2) 0))(define (fast-expt-iter result b n) (cond ((= n 0) 1) ((= n 1) (* result b)) ((even? n) (fast-expt-iter result (* b b) (/ n 2)))...

2011-05-13 13:02:14 159

sicp练习1.12 帕斯卡三角(杨辉三角)

杨辉三角以前在学习c语言时候,用循环很容易实现。由于刚刚接触函数式语言,递归和迭代方式实现循环还没深入我心。下意思的想用链表来实现,但发现自己对scheme的链表操作太不熟悉,总会出现这样那样子的无法自我解释的问题。最后参考了@dennis_zane的pascal实现,dennis_zane是把杨辉三角左对齐,然后根据坐标之间的关系实现:(pascal x y) ,其中x,y为坐标,(pasca...

2011-05-13 08:21:54 264

java动态代理机制原理

Proxy的public static Object newProxyInstance(ClassLoader loader,Class<?>[] interfaces,InvocationHandler h),首先通过getProxyClass 创建一个新的Class 对象,//(Class cl = getProxyClass(loader, interfaces);)ge...

2009-10-13 11:37:00 81

并发的多面性

并发解决的问题:速度和设计可管理性。 更快的执行 : 并发用于多处理器系统中可以吞吐量,但是并发通常却用来提高单处理器上的程序性能。如果但处理器没有阻塞,那么多线程需要线程上下文的转换,程序性能反而会更差,因此之所以在但处理器中需要多线程,是因为程序控制范围之外的阻塞引起的,如果没有任务阻塞,那么在但处理器上使用并发就没有任何意义。 单处理器上性能提高的常见示例是事...

2009-08-27 17:34:00 73

c语言中-x的实现原理

c语言中,-x实现是用取反+1实现,因此x>0||-x<=0不一定都成立,比如x=0x80000000,即x除了符号位是1,其余都是零,10进制值为#include<iostream>int main(){ int x=0x80000000; printf("x=%d/n",x); if(x>0||-x>=0) printf("...

2009-07-25 12:21:00 307

算法导论思考题:6-3Young 矩阵

三.Young 氏矩阵的相关算法.题:一个 m*n 的 Young 氏矩阵(Young tableau) 是一个 m*n 的矩阵,其中每一行的数据都从左到右排序,第一列的数据都从上到下排序.Young氏矩阵中可能会有一些∞ 数据项,表示不存在的元素.所以,Young 氏矩阵可以用来存放 r<= mn 个有限的元素.a).画一个包含{9,16,3,2,4,8,5,14,12} 的4*4...

2008-10-30 21:41:00 162

算法导论习题2.3-7

题目:请给出一个时间复杂度为nlogn的算法,使之能够在给定一个由n个整数的构成的整合S和另一个整数x时,判断出S中是否存在有两个其和等于x的元素。解答:首先对S进行排序,使用合并算法进行排序,排序算法的时间复杂度为nlogn。然后对排序的S从左到右(即从大到小)进行算法,首先锁定一个数i,这个数小于x的一半,然后从这个数的右边开始查找x-i,使用2分法查找,算法的时间复杂度小于nlo...

2008-10-25 15:36:00 65

在nlgn时间内实现逆序对数的计算

数组中逆序对的数量是同运行插入排序产生的移动的数量是相同的,但是选择排序的最差的时间复杂度是n的平方次,但是合并排序最差的是nlogn的时间复杂度。所以应该修改合并排序来计算逆序对数量。在L和R合并的过程中,如果没有移动的话,序列是L+R,所以计算移动的数量就是元素没有移动过R与L与R合并后的位置之间的差值就是移动的数量。 以下代码是实现的算法:#include<iostr...

2008-10-25 11:05:00 95

类MFC实现无参数函数指针保存有参数函数指针

#include <iostream>using namespace std;class A;typedef void ( A:: * PFN)(void); class A{public:void FunA(int num){cout<<"FunA in A num ="<<num<<endl;}};union MM{PFN pfn;v...

2008-08-01 16:49:00 93

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除