这两天都是水题,没有什么想法而言,就是为了熟悉一下感觉。我又给互联网上增加了不少垃圾日志。
昨晚出了点突发事件,原定的写程序事件被用来处理事情了。不过后来我倒是有点想明白了,题目只是很少一点时间在看题目,很忙的时候可以先花几分钟把题目弄明白了,然后在去忙别的事情,这种件的空隙还能想一想思路。不知POJ有什么办法可以把题目批量导出的,我就不用天天费劲上网读题目了,在单位也能抽空瞅两眼。
我坚持两件事情:1。决不直接贴题目的代码 2。每天都写题目
POJ 3006
计划打个表,然后直接搞,看了一下数据很小,应该没有什么问题。
在这里顺便题一下素数筛选法。
以下内容来自Wikipedia:
To find all the prime numbers less than or equal to a given integer n by Eratosthenes' method:
- Create a list of consecutive integers from two to n: (2, 3, 4, ..., n).
- Initially, let p equal 2, the first prime number.
- Strike from the list all multiples of p less than or equal to n. (2p, 3p, 4p, etc.)
- Find the first number remaining on the list after p (this number is the next prime); replace p with this number.
- Repeat steps 3 and 4 until p2 is greater than n.
- All the remaining numbers in the list are prime
后来,欧拉同学提出了另外一个办法,让每个数只要标记一次就ok
A) Start with all the natural numbers except '1' which is not a prime:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ...
^
B) The leftmost number is prime. Multiply each number in the list by this prime and
then discard the products:
(4 6 8 10 12 14 16 18 20 22 24 26 28 30 ... )
These are removed:
4 6 8 10 12 14 16 18 20 22 24 26 28 30
These are left:
2 3 5 7 9 11 13 15 17 19 21 23 25 27 29 ...
^
C) The number after the previous prime is also a prime. Multiply by it each number
in the new list starting from this prime and then discard the products:
(9 15 21 27 33 39 45 51 57 63 69 75 81 87 ...)
These are removed:
9 15 21 27
These are left:
2 3 5 7 11 13 17 19 23 25 29 ...
^
=================================================
2010-7-13 23:47
拆掉了自己的惠普V3159笔记本,心情一片大好,竟然装上以后运行正常了。出来混,迟早要还,之前一直对于拆机器的事情不感兴趣,现在可真是被逼得。
我终于可以去中关村赚取那90块的拆机费了: )
PS:今天中午修好了屋子里面的抽水马桶,心情一片大好。