随笔分类 -  数论(Number Theory)

摘要:sgu 489 Extremal Permutationsgoogle 了一下,发现其实是一个叫做Alternating Permutation的数列,最后又扯出了Euler Number,看的头大。正确的递推公式是: 阅读全文
posted @ 2010-09-01 19:20 superbin 阅读(330) 评论(0) 推荐(0)
摘要:最近发现了一个很有趣的网站,Project Euler上面全是数学题,不过大多需要用编程解决Problem 3:求:600851475143的最大素因子。解:编了个程序,迅速水过,看官方的题解,加了一些优化。其实可以打个素数表继续优化。Problem 4:求:由两个三位数相乘得到的最大的回文数(P = a*b)。解:枚举100~999,判断成绩是否是回文数,求出最大的一个。改进一:可假设a<... 阅读全文
posted @ 2010-08-31 21:46 superbin 阅读(657) 评论(0) 推荐(0)
摘要:Euclid 规则:如果x 和 y 是正整数,且有x≥y,那么gcd(x, y) = gcd(x mod y, y)。证明:待续function Euclid(a, b)Input: Two integers a and b with a > 0 and b > 0Output: gcd(a, b)if b = 0: return areturn Euclid(b, a mod ... 阅读全文
posted @ 2010-05-21 00:10 superbin 阅读(831) 评论(0) 推荐(0)