This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
首先全买酒,喝掉5瓶,有5个瓶子、5个盖子。 | |
全部换掉,喝掉3瓶酒,还有4个瓶子、4个盖子。 | |
全部换掉,喝掉3瓶酒,还有3个瓶子、3个盖子。 | |
借1个瓶子、1个盖子,全部换掉,喝掉3瓶酒,还有2个瓶子、2个盖子。 | |
借2个盖子,全部换掉,喝掉2瓶酒,还有2个瓶子。 | |
换掉,喝掉1瓶酒,还有1个瓶子,1个盖子。 | |
借1个瓶子、3个盖子,喝掉2瓶酒,还有1个瓶子,欠一个盖子。 | |
借1个瓶子,喝掉1瓶酒,也还掉了上一次欠的盖子。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prime?(n, pos = 2**-200) | |
raise "Kidding me?" if n < 2 | |
return true if n == 2 | |
return false if n % 2 == 0 | |
miller(n, Math.log(pos, 0.25).ceil) | |
end | |
def miller(n, k) | |
rnd = Random.new | |
s, d = miller_factorize(n - 1) |