The post Project Euler 318 Solution appeared first on Dreamshire.
]]>Project Euler 318: Consider the real number √2+√3.
When we calculate the even powers of √2+√3
we get:
(√2+√3)^{2} = 9.898979485566356…
(√2+√3)^{4} = 97.98979485566356…
(√2+√3)^{6} = 969.998969071069263…
(√2+√3)^{8} = 9601.99989585502907…
(√2+√3)^{10} = 95049.999989479221…
(√2+√3)^{12} = 940897.9999989371855…
(√2+√3)^{14} = 9313929.99999989263…
(√2+√3)^{16} = 92198401.99999998915…
It looks like that the number of consecutive nines at the beginning of the fractional part of these powers is non-decreasing.
In fact it can be proven that the fractional part of (√2+√3)^{2n} approaches 1 for large n.
Consider all real numbers of the form √p+√q with p and q positive integers and p<q, such that the fractional part
of (√p+√q)^{2n} approaches 1 for large n.
Let C(p,q,n) be the number of consecutive nines at the beginning of the fractional part of
(√p+√q)^{2n}.
Let N(p,q) be the minimal value of n such that C(p,q,n) ≥ 2011.
Find ∑N(p,q) for p+q ≤ 2011.
The post Project Euler 318 Solution appeared first on Dreamshire.
]]>The post Project Euler 317 Solution appeared first on Dreamshire.
]]>A firecracker explodes at a height of 100 m above level ground. It breaks into a large number of very small fragments, which move in every direction; all of them have the same initial velocity of 20 m/s.
We assume that the fragments move without air resistance, in a uniform gravitational field with g=9.81 m/s^{2}.
Find the volume (in m^{3}) of the region through which the fragments move before reaching the ground.
Give your answer rounded to four decimal places.
The post Project Euler 317 Solution appeared first on Dreamshire.
]]>The post Project Euler 371 Solution appeared first on Dreamshire.
]]>Oregon licence plates consist of three letters followed by a three digit number (each digit can be from [0..9]).
While driving to work Seth plays the following game:
Whenever the numbers of two licence plates seen on his trip add to 1000 that’s a win.
E.g. MIC-012 and HAN-988 is a win and RYU-500 and SET-500 too. (as long as he sees them in the same trip).
Find the expected number of plates he needs to see for a win.
Give your answer rounded to 8 decimal places behind the decimal point.
Note: We assume that each licence plate seen is equally likely to have any three digit number on it.
The post Project Euler 371 Solution appeared first on Dreamshire.
]]>The post Project Euler 327 Solution appeared first on Dreamshire.
]]>A series of three rooms are connected to each other by automatic doors.
Each door is operated by a security card. Once you enter a room the door automatically closes and that security card cannot be used again. A machine at the start will dispense an unlimited number of cards, but each room (including the starting room) contains scanners and if they detect that you are holding more than three security cards or if they detect an unattended security card on the floor, then all the doors will become permanently locked. However, each room contains a box where you may safely store any number of security cards for use at a later stage.
If you simply tried to travel through the rooms one at a time then as you entered room 3 you would have used all three cards and would be trapped in that room forever!
However, if you make use of the storage boxes, then escape is possible. For example, you could enter room 1 using your first card, place one card in the storage box, and use your third card to exit the room back to the start. Then after collecting three more cards from the dispensing machine you could use one to enter room 1 and collect the card you placed in the box a moment ago. You now have three cards again and will be able to travel through the remaining three doors. This method allows you to travel through all three rooms using six security cards in total.
It is possible to travel through six rooms using a total of 123 security cards while carrying a maximum of 3 cards.
Let C be the maximum number of cards which can be carried at any time.
Let R be the number of rooms to travel through.
Let M(C,R) be the minimum number of cards required from the dispensing machine to travel through R rooms carrying up to a maximum of C cards at any time.
For example, M(3,6)=123 and M(4,6)=23.
And, ΣM(C,6)=146 for 3 ≤ C ≤ 4.
You are given that ΣM(C,10)=10382 for 3 ≤ C ≤ 10.
Find ΣM(C,30) for 3 ≤ C ≤ 40.
The post Project Euler 327 Solution appeared first on Dreamshire.
]]>The post Project Euler 301 Solution appeared first on Dreamshire.
]]>Nim is a game played with heaps of stones, where two players take it in turn to remove any number of stones from any heap until no stones remain.
We’ll consider the three-heap normal-play version of Nim, which works as follows:
– At the start of the game there are three heaps of stones.
– On his turn the player removes any positive number of stones from any single heap.
– The first player unable to move (because no stones remain) loses.
If (n_{1},n_{2},n_{3}) indicates a Nim position consisting of heaps of size n_{1}, n_{2} and n_{3} then there is a simple function X(n_{1},n_{2},n_{3}) — that you may look up or attempt to deduce for yourself — that returns:
For example X(1,2,3) = 0 because, no matter what the current player does, his opponent can respond with a move that leaves two heaps of equal size, at which point every move by the current player can be mirrored by his opponent until no stones remain; so the current player loses. To illustrate:
– current player moves to (1,2,1)
– opponent moves to (1,0,1)
– current player moves to (0,0,1)
– opponent moves to (0,0,0), and so wins.
For how many positive integers n ≤ 2^{30} does X(n,2n,3n) = 0 ?
Classic use of the Fibonacci sequence. Just find the Fibonacci Number F_{L+2}, where L is the 2’s exponent.
fibonacci
is listed in Common Functions and Routines for Project EulerThe post Project Euler 301 Solution appeared first on Dreamshire.
]]>