An infinite number of people (numbered $1$, $2$, $3$, etc.) are lined up to get a room at Hilbert’s newest infinite hotel. The hotel contains an infinite number of floors (numbered $1$, $2$, $3$, etc.), and each floor contains an infinite number of rooms (numbered $1$, $2$, $3$, etc.).
Initially the hotel is empty. Hilbert declares a rule on how the $n$th person is assigned a room: person $n$ gets the first vacant room in the lowest numbered floor satisfying either of the following:
the floor is empty
the floor is not empty, and if the latest person taking a room in that floor is person $m$, then $m + n$ is a perfect square
Person $1$ gets room $1$ in floor $1$ since floor $1$ is empty.
Person $2$ does not get room $2$ in floor $1$ since $1 + 2 = 3$ is not a perfect square.
Person $2$ instead gets room $1$ in floor $2$ since floor $2$ is empty.
Person $3$ gets room $2$ in floor $1$ since $1 + 3 = 4$ is a perfect square.
Eventually, every person in the line gets a room in the hotel.
Define $P(f, r)$ to be $n$ if person $n$ occupies room $r$ in floor $f$, and $0$ if no person occupies the room. Here are a few examples:
$P(1, 1) = 1$
$P(1, 2) = 3$
$P(2, 1) = 2$
$P(10, 20) = 440$
$P(25, 75) = 4863$
$P(99, 100) = 19454$
Find the sum of all $P(f, r)$ for all positive $f$ and $r$ such that $f \times r = 71328803586048$ and give the last $8$ digits as your answer.
This problem can be solved using mathematical induction.
First, we note that for a floor f, the last person to check into the floor (who occupies room n) satisfies f+n^2.
Let $S(f,n) = f + n^2$. For example, when n = 1 and f = 1, $S(f,n) = S(1,1) = 1 + 1^2 = 2$, or in other words Person 2 is the last person to check into the first floor.
Also let $f*r = N$.
Then $P(f, r) = S(f, r-1) = f + (r-1)^2$.
To find the sum of all $P(f, r)$ for all positive $f$ and $r$ such that $f * r = N$ is then to find $Sum_{f*r = N} f + (r-1)^2$.
This summation can be split into two parts: $Sum_{f*r = N} f$ and $Sum_{f*r = N} (r-1)^2$.
The first part equals to f*N when f divides N, and the second part equals to $(r^2 – 2*r + 1)*r$ when f divides N.
So to simplify the problem, we can find all factors of N and feed them into f. For each f, calculate $(f*N + (r^2 – 2*r + 1)*r)$, where r = N/f, and sum them all up.
For the specific number 71328803586048, we can use the above process to find the sum. There is an efficient way to factor N using its prime factorization, which is 2^14 * 3^2 * 5^2 * 7^2 * 11^2 * 13^2.
Now we can use dynamic programming to generate all divisors of N and then sum up all possible products ($f * N + (r^2 – 2*r + 1)*r$ where r = N/f).
In the end, we find that the sum of all $P(f, r)$ for which $f * r = 71328803586048$ is 379577642293166288, and truncating the last 8 digits gives the solution 293166288.
More Answers:
Largest Roots of Cubic PolynomialsPrime Generating Integers
Cyclic Numbers