Circles $A$ and $B$ are tangent to each other and to line $L$ at three distinct points.
Circle $C$ is inside the space between $A$, $B$ and $L$, and tangent to all three.
Let $r_A$, $r_B$ and $r_C$ be the radii of $A$, $B$ and $C$ respectively.
Let $S(n) = \sum r_A + r_B + r_C$, for $0 \lt r_A \le r_B \le n$ where $r_A$, $r_B$ and $r_C$ are integers.
The only solution for $0 \lt r_A \le r_B \le 5$ is $r_A = 4$, $r_B = 4$ and $r_C = 1$, so $S(5) = 4 + 4 + 1 = 9$.
You are also given $S(100) = 3072$.
Find $S(10^9)$.
To solve this problem, we will use dynamic programming to compute the number of paths from $(0,0)$ to $(W,H)$.
First, let’s define a function `fibonacci(n)` that returns the n-th Fibonacci number. We can implement this function using the recursive definition of Fibonacci numbers:
“`python
def fibonacci(n):
if n <= 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
```
Next, we define a function `count_paths(W, H)` that computes and returns the number of paths from $(0,0)$ to $(W,H)$. We will use a 2D matrix to store the intermediate results.
```python
def count_paths(W, H):
# Create a (W+1)x(H+1) matrix to store the intermediate results
dp = [[0] * (H+1) for _ in range(W+1)]
# Initialize the base cases
dp[0][0] = 1
# Compute the number of paths for each cell
for i in range(W+1):
for j in range(H+1):
# Check if the distance is a Fibonacci number
if fibonacci(i*i + j*j) != 0:
# Count paths from the previous cells
if i > 0:
dp[i][j] += dp[i-1][j]
if j > 0:
dp[i][j] += dp[i][j-1]
# Return the number of paths from (0,0) to (W,H)
return dp[W][H]
“`
Now, we can compute the value of `F(10000, 10000)` modulo `1_000_000_007` by calling the `count_paths` function.
“`python
result = count_paths(10_000, 10_000) % 1_000_000_007
print(result)
“`
This will give us the desired value of `F(10_000, 10_000) % 1_000_000_007`.
More Answers:
Clock SequenceShortest Lattice Vector
Divisor Nim