id
int32 | title
string | problem
string | question_latex
string | question_html
string | numerical_answer
string | pub_date
string | solved_by
string | diff_rate
string | difficulty
string |
---|---|---|---|---|---|---|---|---|---|
301 | Nim | 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 each player's turn, the player may remove 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, which you may look up or attempt to deduce for yourself, $X(n_1,n_2,n_3)$ that returns:
zero if, with perfect strategy, the player about to move will eventually lose; or
non-zero if, with perfect strategy, the player about to move will eventually win.
For example $X(1,2,3) = 0$ because, no matter what the current player does, the 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 the 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 \le 2^{30}$ does $X(n,2n,3n) = 0$ ? | 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 each player's turn, the player may remove 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, which you may look up or attempt to deduce for yourself, $X(n_1,n_2,n_3)$ that returns:
zero if, with perfect strategy, the player about to move will eventually lose; or
non-zero if, with perfect strategy, the player about to move will eventually win.
For example $X(1,2,3) = 0$ because, no matter what the current player does, the 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 the 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 \le 2^{30}$ does $X(n,2n,3n) = 0$ ? | <p><dfn>Nim</dfn> 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.</p>
<p>We'll consider the three-heap normal-play version of Nim, which works as follows:</p>
<ul><li>At the start of the game there are three heaps of stones.</li>
<li>On each player's turn, the player may remove any positive number of stones from any single heap.</li>
<li>The first player unable to move (because no stones remain) loses.</li>
</ul><p>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, which you may look up or attempt to deduce for yourself, $X(n_1,n_2,n_3)$ that returns:</p>
<ul><li>zero if, with perfect strategy, the player about to move will eventually lose; or</li>
<li>non-zero if, with perfect strategy, the player about to move will eventually win.</li>
</ul><p>For example $X(1,2,3) = 0$ because, no matter what the current player does, the 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 the opponent until no stones remain; so the current player loses. To illustrate:</p>
<ul><li>current player moves to $(1,2,1)$</li>
<li>opponent moves to $(1,0,1)$</li>
<li>current player moves to $(0,0,1)$</li>
<li>opponent moves to $(0,0,0)$, and so wins.</li>
</ul><p>For how many positive integers $n \le 2^{30}$ does $X(n,2n,3n) = 0$ ?</p> | 2178309 | Saturday, 11th September 2010, 04:00 pm | 7134 | 15% | easy |
753 | Fermat Equation | Fermat's Last Theorem states that no three positive integers $a$, $b$, $c$ satisfy the equation
$$a^n+b^n=c^n$$
for any integer value of $n$ greater than 2.
For this problem we are only considering the case $n=3$. For certain values of $p$, it is possible to solve the congruence equation:
$$a^3+b^3 \equiv c^3 \pmod{p}$$
For a prime $p$, we define $F(p)$ as the number of integer solutions to this equation for $1 \le a,b,c < p$.
You are given $F(5) = 12$ and $F(7) = 0$.
Find the sum of $F(p)$ over all primes $p$ less than $6\,000\,000$. | Fermat's Last Theorem states that no three positive integers $a$, $b$, $c$ satisfy the equation
$$a^n+b^n=c^n$$
for any integer value of $n$ greater than 2.
For this problem we are only considering the case $n=3$. For certain values of $p$, it is possible to solve the congruence equation:
$$a^3+b^3 \equiv c^3 \pmod{p}$$
For a prime $p$, we define $F(p)$ as the number of integer solutions to this equation for $1 \le a,b,c < p$.
You are given $F(5) = 12$ and $F(7) = 0$.
Find the sum of $F(p)$ over all primes $p$ less than $6\,000\,000$. | <p>Fermat's Last Theorem states that no three positive integers $a$, $b$, $c$ satisfy the equation
$$a^n+b^n=c^n$$
for any integer value of $n$ greater than 2.</p>
<p>For this problem we are only considering the case $n=3$. For certain values of $p$, it is possible to solve the congruence equation:
$$a^3+b^3 \equiv c^3 \pmod{p}$$</p>
<p>For a prime $p$, we define $F(p)$ as the number of integer solutions to this equation for $1 \le a,b,c < p$.</p>
<p>You are given $F(5) = 12$ and $F(7) = 0$.</p>
<p>Find the sum of $F(p)$ over all primes $p$ less than $6\,000\,000$.</p> | 4714126766770661630 | Sunday, 28th March 2021, 05:00 am | 425 | 40% | medium |
623 | Lambda Count | The lambda-calculus is a universal model of computation at the core of functional programming languages. It is based on lambda-terms, a minimal programming language featuring only function definitions, function calls and variables. Lambda-terms are built according to the following rules:
Any variable $x$ (single letter, from some infinite alphabet) is a lambda-term.
If $M$ and $N$ are lambda-terms, then $(M N)$ is a lambda-term, called the application of $M$ to $N$.
If $x$ is a variable and $M$ is a term, then $(\lambda x. M)$ is a lambda-term, called an abstraction. An abstraction defines an anonymous function, taking $x$ as parameter and sending back $M$.
A lambda-term $T$ is said to be closed if for all variables $x$, all occurrences of $x$ within $T$ are contained within some abstraction $(\lambda x. M)$ in $T$. The smallest such abstraction is said to bind the occurrence of the variable $x$. In other words, a lambda-term is closed if all its variables are bound to parameters of enclosing functions definitions. For example, the term $(\lambda x. x)$ is closed, while the term $(\lambda x. (x y))$ is not because $y$ is not bound.
Also, we can rename variables as long as no binding abstraction changes. This means that $(\lambda x. x)$ and $(\lambda y. y)$ should be considered equivalent since we merely renamed a parameter. Two terms equivalent modulo such renaming are called $\alpha$-equivalent. Note that $(\lambda x. (\lambda y. (x y)))$ and $(\lambda x. (\lambda x. (x x)))$ are not $\alpha$-equivalent, since the abstraction binding the first variable was the outer one and becomes the inner one. However, $(\lambda x. (\lambda y. (x y)))$ and $(\lambda y. (\lambda x. (y x)))$ are $\alpha$-equivalent.
The following table regroups the lambda-terms that can be written with at most $15$ symbols, symbols being parenthesis, $\lambda$, dot and variables.
\[\begin{array}{|c|c|c|c|}
\hline
(\lambda x.x) & (\lambda x.(x x)) & (\lambda x.(\lambda y.x)) & (\lambda x.(\lambda y.y)) \\
\hline
(\lambda x.(x (x x))) & (\lambda x.((x x) x)) & (\lambda x.(\lambda y.(x x))) & (\lambda x.(\lambda y.(x y))) \\
\hline
(\lambda x.(\lambda y.(y x))) & (\lambda x.(\lambda y.(y y))) & (\lambda x.(x (\lambda y.x))) & (\lambda x.(x (\lambda y.y))) \\
\hline
(\lambda x.((\lambda y.x) x)) & (\lambda x.((\lambda y.y) x)) & ((\lambda x.x) (\lambda x.x)) & (\lambda x.(x (x (x x)))) \\
\hline
(\lambda x.(x ((x x) x))) & (\lambda x.((x x) (x x))) & (\lambda x.((x (x x)) x)) & (\lambda x.(((x x) x) x)) \\
\hline
\end{array}\]
Let be $\Lambda(n)$ the number of distinct closed lambda-terms that can be written using at most $n$ symbols, where terms that are $\alpha$-equivalent to one another should be counted only once. You are given that $\Lambda(6) = 1$, $\Lambda(9) = 2$, $\Lambda(15) = 20$ and $\Lambda(35) = 3166438$.
Find $\Lambda(2000)$. Give the answer modulo $1\,000\,000\,007$. | The lambda-calculus is a universal model of computation at the core of functional programming languages. It is based on lambda-terms, a minimal programming language featuring only function definitions, function calls and variables. Lambda-terms are built according to the following rules:
Any variable $x$ (single letter, from some infinite alphabet) is a lambda-term.
If $M$ and $N$ are lambda-terms, then $(M N)$ is a lambda-term, called the application of $M$ to $N$.
If $x$ is a variable and $M$ is a term, then $(\lambda x. M)$ is a lambda-term, called an abstraction. An abstraction defines an anonymous function, taking $x$ as parameter and sending back $M$.
A lambda-term $T$ is said to be closed if for all variables $x$, all occurrences of $x$ within $T$ are contained within some abstraction $(\lambda x. M)$ in $T$. The smallest such abstraction is said to bind the occurrence of the variable $x$. In other words, a lambda-term is closed if all its variables are bound to parameters of enclosing functions definitions. For example, the term $(\lambda x. x)$ is closed, while the term $(\lambda x. (x y))$ is not because $y$ is not bound.
Also, we can rename variables as long as no binding abstraction changes. This means that $(\lambda x. x)$ and $(\lambda y. y)$ should be considered equivalent since we merely renamed a parameter. Two terms equivalent modulo such renaming are called $\alpha$-equivalent. Note that $(\lambda x. (\lambda y. (x y)))$ and $(\lambda x. (\lambda x. (x x)))$ are not $\alpha$-equivalent, since the abstraction binding the first variable was the outer one and becomes the inner one. However, $(\lambda x. (\lambda y. (x y)))$ and $(\lambda y. (\lambda x. (y x)))$ are $\alpha$-equivalent.
The following table regroups the lambda-terms that can be written with at most $15$ symbols, symbols being parenthesis, $\lambda$, dot and variables.
\[\begin{array}{|c|c|c|c|}
\hline
(\lambda x.x) & (\lambda x.(x x)) & (\lambda x.(\lambda y.x)) & (\lambda x.(\lambda y.y)) \\
\hline
(\lambda x.(x (x x))) & (\lambda x.((x x) x)) & (\lambda x.(\lambda y.(x x))) & (\lambda x.(\lambda y.(x y))) \\
\hline
(\lambda x.(\lambda y.(y x))) & (\lambda x.(\lambda y.(y y))) & (\lambda x.(x (\lambda y.x))) & (\lambda x.(x (\lambda y.y))) \\
\hline
(\lambda x.((\lambda y.x) x)) & (\lambda x.((\lambda y.y) x)) & ((\lambda x.x) (\lambda x.x)) & (\lambda x.(x (x (x x)))) \\
\hline
(\lambda x.(x ((x x) x))) & (\lambda x.((x x) (x x))) & (\lambda x.((x (x x)) x)) & (\lambda x.(((x x) x) x)) \\
\hline
\end{array}\]
Let be $\Lambda(n)$ the number of distinct closed lambda-terms that can be written using at most $n$ symbols, where terms that are $\alpha$-equivalent to one another should be counted only once. You are given that $\Lambda(6) = 1$, $\Lambda(9) = 2$, $\Lambda(15) = 20$ and $\Lambda(35) = 3166438$.
Find $\Lambda(2000)$. Give the answer modulo $1\,000\,000\,007$. | <p>The <strong>lambda-calculus</strong> is a universal model of computation at the core of functional programming languages. It is based on <strong>lambda-terms</strong>, a minimal programming language featuring only function definitions, function calls and variables. Lambda-terms are built according to the following rules:</p>
<ul>
<li>Any <strong>variable</strong> $x$ (single letter, from some infinite alphabet) is a lambda-term.</li>
<li>If $M$ and $N$ are lambda-terms, then $(M N)$ is a lambda-term, called the <strong>application</strong> of $M$ to $N$.</li>
<li>If $x$ is a variable and $M$ is a term, then $(\lambda x. M)$ is a lambda-term, called an <strong>abstraction</strong>. An abstraction defines an anonymous function, taking $x$ as parameter and sending back $M$.</li>
</ul>
<p>A lambda-term $T$ is said to be <strong>closed</strong> if for all variables $x$, all occurrences of $x$ within $T$ are contained within some abstraction $(\lambda x. M)$ in $T$. The smallest such abstraction is said to <strong>bind</strong> the occurrence of the variable $x$. In other words, a lambda-term is closed if all its variables are bound to parameters of enclosing functions definitions. For example, the term $(\lambda x. x)$ is closed, while the term $(\lambda x. (x y))$ is not because $y$ is not bound.</p>
<p>Also, we can rename variables as long as no binding abstraction changes. This means that $(\lambda x. x)$ and $(\lambda y. y)$ should be considered equivalent since we merely renamed a parameter. Two terms equivalent modulo such renaming are called <i>$\alpha$-equivalent</i>. Note that $(\lambda x. (\lambda y. (x y)))$ and $(\lambda x. (\lambda x. (x x)))$ are not $\alpha$-equivalent, since the abstraction binding the first variable was the outer one and becomes the inner one. However, $(\lambda x. (\lambda y. (x y)))$ and $(\lambda y. (\lambda x. (y x)))$ are $\alpha$-equivalent.</p>
<p>The following table regroups the lambda-terms that can be written with at most $15$ symbols, symbols being parenthesis, $\lambda$, dot and variables.</p>
\[\begin{array}{|c|c|c|c|}
\hline
(\lambda x.x) & (\lambda x.(x x)) & (\lambda x.(\lambda y.x)) & (\lambda x.(\lambda y.y)) \\
\hline
(\lambda x.(x (x x))) & (\lambda x.((x x) x)) & (\lambda x.(\lambda y.(x x))) & (\lambda x.(\lambda y.(x y))) \\
\hline
(\lambda x.(\lambda y.(y x))) & (\lambda x.(\lambda y.(y y))) & (\lambda x.(x (\lambda y.x))) & (\lambda x.(x (\lambda y.y))) \\
\hline
(\lambda x.((\lambda y.x) x)) & (\lambda x.((\lambda y.y) x)) & ((\lambda x.x) (\lambda x.x)) & (\lambda x.(x (x (x x)))) \\
\hline
(\lambda x.(x ((x x) x))) & (\lambda x.((x x) (x x))) & (\lambda x.((x (x x)) x)) & (\lambda x.(((x x) x) x)) \\
\hline
\end{array}\]
<p>Let be $\Lambda(n)$ the number of distinct closed lambda-terms that can be written using at most $n$ symbols, where terms that are $\alpha$-equivalent to one another should be counted only once. You are given that $\Lambda(6) = 1$, $\Lambda(9) = 2$, $\Lambda(15) = 20$ and $\Lambda(35) = 3166438$.</p>
<p>Find $\Lambda(2000)$. Give the answer modulo $1\,000\,000\,007$.</p> | 3679796 | Sunday, 25th March 2018, 10:00 am | 358 | 45% | medium |
196 | Prime Triplets | Build a triangle from all positive integers in the following way:
1
2 3
4 5 6
7 8 9 1011 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 2829 30 31 32 33 34 35 3637 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
. . .
Each positive integer has up to eight neighbours in the triangle.
A set of three primes is called a prime triplet if one of the three primes has the other two as neighbours in the triangle.
For example, in the second row, the prime numbers $2$ and $3$ are elements of some prime triplet.
If row $8$ is considered, it contains two primes which are elements of some prime triplet, i.e. $29$ and $31$.
If row $9$ is considered, it contains only one prime which is an element of some prime triplet: $37$.
Define $S(n)$ as the sum of the primes in row $n$ which are elements of any prime triplet.
Then $S(8)=60$ and $S(9)=37$.
You are given that $S(10000)=950007619$.
Find $S(5678027) + S(7208785)$. | Build a triangle from all positive integers in the following way:
1
2 3
4 5 6
7 8 9 1011 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 2829 30 31 32 33 34 35 3637 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
. . .
Each positive integer has up to eight neighbours in the triangle.
A set of three primes is called a prime triplet if one of the three primes has the other two as neighbours in the triangle.
For example, in the second row, the prime numbers $2$ and $3$ are elements of some prime triplet.
If row $8$ is considered, it contains two primes which are elements of some prime triplet, i.e. $29$ and $31$.
If row $9$ is considered, it contains only one prime which is an element of some prime triplet: $37$.
Define $S(n)$ as the sum of the primes in row $n$ which are elements of any prime triplet.
Then $S(8)=60$ and $S(9)=37$.
You are given that $S(10000)=950007619$.
Find $S(5678027) + S(7208785)$. | <p>Build a triangle from all positive integers in the following way:</p>
<p style="font-family:'courier new', monospace;font-weight:bold;margin-left:50px;"> 1<br/>
<span style="color:#FF0000;">2</span> <span style="color:#FF0000;">3</span><br/>
4 <span style="color:#FF0000;">5</span> 6<br/>
<span style="color:#FF0000;">7</span> 8 9 10<br/><span style="color:#FF0000;">11</span> 12 <span style="color:#FF0000;">13</span> 14 15<br/>
16 <span style="color:#FF0000;">17</span> 18 <span style="color:#FF0000;">19</span> 20 21<br/>
22 <span style="color:#FF0000;">23</span> 24 25 26 27 28<br/><span style="color:#FF0000;">29</span> 30 <span style="color:#FF0000;">31</span> 32 33 34 35 36<br/><span style="color:#FF0000;">37</span> 38 39 40 <span style="color:#FF0000;">41</span> 42 <span style="color:#FF0000;">43</span> 44 45<br/>
46 <span style="color:#FF0000;">47</span> 48 49 50 51 52 <span style="color:#FF0000;">53</span> 54 55<br/>
56 57 58 <span style="color:#FF0000;">59</span> 60 <span style="color:#FF0000;">61</span> 62 63 64 65 66<br/>
. . .</p>
<p>Each positive integer has up to eight neighbours in the triangle.</p>
<p>A set of three primes is called a <dfn>prime triplet</dfn> if one of the three primes has the other two as neighbours in the triangle.</p>
<p>For example, in the second row, the prime numbers $2$ and $3$ are elements of some prime triplet.</p>
<p>If row $8$ is considered, it contains two primes which are elements of some prime triplet, i.e. $29$ and $31$.<br/>
If row $9$ is considered, it contains only one prime which is an element of some prime triplet: $37$.</p>
<p>Define $S(n)$ as the sum of the primes in row $n$ which are elements of any prime triplet.<br/>
Then $S(8)=60$ and $S(9)=37$.</p>
<p>You are given that $S(10000)=950007619$.</p>
<p>Find $S(5678027) + S(7208785)$.</p> | 322303240771079935 | Friday, 30th May 2008, 06:00 pm | 2904 | 65% | hard |
35 | Circular Primes | The number, $197$, is called a circular prime because all rotations of the digits: $197$, $971$, and $719$, are themselves prime.
There are thirteen such primes below $100$: $2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79$, and $97$.
How many circular primes are there below one million? | The number, $197$, is called a circular prime because all rotations of the digits: $197$, $971$, and $719$, are themselves prime.
There are thirteen such primes below $100$: $2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79$, and $97$.
How many circular primes are there below one million? | <p>The number, $197$, is called a circular prime because all rotations of the digits: $197$, $971$, and $719$, are themselves prime.</p>
<p>There are thirteen such primes below $100$: $2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79$, and $97$.</p>
<p>How many circular primes are there below one million?</p> | 55 | Friday, 17th January 2003, 06:00 pm | 92333 | 5% | easy |
287 | Quadtree Encoding (a Simple Compression Algorithm) | The quadtree encoding allows us to describe a $2^N \times 2^N$ black and white image as a sequence of bits (0 and 1). Those sequences are to be read from left to right like this:
the first bit deals with the complete $2^N \times 2^N$ region;
"0" denotes a split:
the current $2^n \times 2^n$ region is divided into $4$ sub-regions of dimension $2^{n - 1} \times 2^{n - 1}$,
the next bits contains the description of the top left, top right, bottom left and bottom right sub-regions - in that order;
"10" indicates that the current region contains only black pixels;
"11" indicates that the current region contains only white pixels.Consider the following $4 \times 4$ image (colored marks denote places where a split can occur):
This image can be described by several sequences, for example :
"001010101001011111011010101010", of length $30$, or
"0100101111101110", of length $16$, which is the minimal sequence for this image.
For a positive integer $N$, define $D_N$ as the $2^N \times 2^N$ image with the following coloring scheme:
the pixel with coordinates $x = 0, y = 0$ corresponds to the bottom left pixel,
if $(x - 2^{N - 1})^2 + (y - 2^{N - 1})^2 \le 2^{2N - 2}$ then the pixel is black,
otherwise the pixel is white.What is the length of the minimal sequence describing $D_{24}$? | The quadtree encoding allows us to describe a $2^N \times 2^N$ black and white image as a sequence of bits (0 and 1). Those sequences are to be read from left to right like this:
the first bit deals with the complete $2^N \times 2^N$ region;
"0" denotes a split:
the current $2^n \times 2^n$ region is divided into $4$ sub-regions of dimension $2^{n - 1} \times 2^{n - 1}$,
the next bits contains the description of the top left, top right, bottom left and bottom right sub-regions - in that order;
"10" indicates that the current region contains only black pixels;
"11" indicates that the current region contains only white pixels.Consider the following $4 \times 4$ image (colored marks denote places where a split can occur):
This image can be described by several sequences, for example :
"001010101001011111011010101010", of length $30$, or
"0100101111101110", of length $16$, which is the minimal sequence for this image.
For a positive integer $N$, define $D_N$ as the $2^N \times 2^N$ image with the following coloring scheme:
the pixel with coordinates $x = 0, y = 0$ corresponds to the bottom left pixel,
if $(x - 2^{N - 1})^2 + (y - 2^{N - 1})^2 \le 2^{2N - 2}$ then the pixel is black,
otherwise the pixel is white.What is the length of the minimal sequence describing $D_{24}$? | <p>The quadtree encoding allows us to describe a $2^N \times 2^N$ black and white image as a sequence of bits (0 and 1). Those sequences are to be read from left to right like this:
</p><ul><li>the first bit deals with the complete $2^N \times 2^N$ region;</li>
<li>"0" denotes a split:
<br/>the current $2^n \times 2^n$ region is divided into $4$ sub-regions of dimension $2^{n - 1} \times 2^{n - 1}$,<br/>
the next bits contains the description of the top left, top right, bottom left and bottom right sub-regions - in that order;</li>
<li>"10" indicates that the current region contains only black pixels;</li>
<li>"11" indicates that the current region contains only white pixels.</li></ul><p>Consider the following $4 \times 4$ image (colored marks denote places where a split can occur):</p>
<div class="center"><img alt="0287_quadtree.gif" class="dark_img" src="resources/images/0287_quadtree.gif?1678992056"/></div>
<p>This image can be described by several sequences, for example :
"<span class="red strong">0</span><span class="blue strong">0</span>10101010<span class="green strong">0</span>1011111011<span class="orange strong">0</span>10101010", of length $30$, or<br/>
"<span class="red strong">0</span>10<span class="green strong"><b>0</b></span>101111101110", of length $16$, which is the minimal sequence for this image.</p>
<p>For a positive integer $N$, define $D_N$ as the $2^N \times 2^N$ image with the following coloring scheme:
</p><ul><li>the pixel with coordinates $x = 0, y = 0$ corresponds to the bottom left pixel,</li>
<li>if $(x - 2^{N - 1})^2 + (y - 2^{N - 1})^2 \le 2^{2N - 2}$ then the pixel is black,</li>
<li>otherwise the pixel is white.</li></ul><p>What is the length of the minimal sequence describing $D_{24}$?</p> | 313135496 | Saturday, 10th April 2010, 09:00 am | 1605 | 40% | medium |
315 | Digital Root Clocks | Sam and Max are asked to transform two digital clocks into two "digital root" clocks.
A digital root clock is a digital clock that calculates digital roots step by step.
When a clock is fed a number, it will show it and then it will start the calculation, showing all the intermediate values until it gets to the result.
For example, if the clock is fed the number 137, it will show: "137" → "11" → "2" and then it will go black, waiting for the next number.
Every digital number consists of some light segments: three horizontal (top, middle, bottom) and four vertical (top-left, top-right, bottom-left, bottom-right).
Number "1" is made of vertical top-right and bottom-right, number "4" is made by middle horizontal and vertical top-left, top-right and bottom-right. Number "8" lights them all.
The clocks consume energy only when segments are turned on/off.
To turn on a "2" will cost 5 transitions, while a "7" will cost only 4 transitions.
Sam and Max built two different clocks.
Sam's clock is fed e.g. number 137: the clock shows "137", then the panel is turned off, then the next number ("11") is turned on, then the panel is turned off again and finally the last number ("2") is turned on and, after some time, off.
For the example, with number 137, Sam's clock requires:"137"
:
(2 + 5 + 4) × 2 = 22 transitions ("137" on/off).
"11"
:
(2 + 2) × 2 = 8 transitions ("11" on/off).
"2"
:
(5) × 2 = 10 transitions ("2" on/off).
For a grand total of 40 transitions.
Max's clock works differently. Instead of turning off the whole panel, it is smart enough to turn off only those segments that won't be needed for the next number.
For number 137, Max's clock requires:"137"
:
2 + 5 + 4 = 11 transitions ("137" on)
7 transitions (to turn off the segments that are not needed for number "11").
"11"
:
0 transitions (number "11" is already turned on correctly)
3 transitions (to turn off the first "1" and the bottom part of the second "1";
the top part is common with number "2").
"2"
:
4 transitions (to turn on the remaining segments in order to get a "2")
5 transitions (to turn off number "2").
For a grand total of 30 transitions.
Of course, Max's clock consumes less power than Sam's one.
The two clocks are fed all the prime numbers between A = 107 and B = 2×107.
Find the difference between the total number of transitions needed by Sam's clock and that needed by Max's one. | Sam and Max are asked to transform two digital clocks into two "digital root" clocks.
A digital root clock is a digital clock that calculates digital roots step by step.
When a clock is fed a number, it will show it and then it will start the calculation, showing all the intermediate values until it gets to the result.
For example, if the clock is fed the number 137, it will show: "137" → "11" → "2" and then it will go black, waiting for the next number.
Every digital number consists of some light segments: three horizontal (top, middle, bottom) and four vertical (top-left, top-right, bottom-left, bottom-right).
Number "1" is made of vertical top-right and bottom-right, number "4" is made by middle horizontal and vertical top-left, top-right and bottom-right. Number "8" lights them all.
The clocks consume energy only when segments are turned on/off.
To turn on a "2" will cost 5 transitions, while a "7" will cost only 4 transitions.
Sam and Max built two different clocks.
Sam's clock is fed e.g. number 137: the clock shows "137", then the panel is turned off, then the next number ("11") is turned on, then the panel is turned off again and finally the last number ("2") is turned on and, after some time, off.
For the example, with number 137, Sam's clock requires:"137"
:
(2 + 5 + 4) × 2 = 22 transitions ("137" on/off).
"11"
:
(2 + 2) × 2 = 8 transitions ("11" on/off).
"2"
:
(5) × 2 = 10 transitions ("2" on/off).
For a grand total of 40 transitions.
Max's clock works differently. Instead of turning off the whole panel, it is smart enough to turn off only those segments that won't be needed for the next number.
For number 137, Max's clock requires:"137"
:
2 + 5 + 4 = 11 transitions ("137" on)
7 transitions (to turn off the segments that are not needed for number "11").
"11"
:
0 transitions (number "11" is already turned on correctly)
3 transitions (to turn off the first "1" and the bottom part of the second "1";
the top part is common with number "2").
"2"
:
4 transitions (to turn on the remaining segments in order to get a "2")
5 transitions (to turn off number "2").
For a grand total of 30 transitions.
Of course, Max's clock consumes less power than Sam's one.
The two clocks are fed all the prime numbers between A = 107 and B = 2×107.
Find the difference between the total number of transitions needed by Sam's clock and that needed by Max's one. | <p></p><div align="center"><img alt="0315_clocks.gif" src="resources/images/0315_clocks.gif?1678992056"/></div>
<p>Sam and Max are asked to transform two digital clocks into two "digital root" clocks.<br/>
A digital root clock is a digital clock that calculates digital roots step by step.</p>
<p>When a clock is fed a number, it will show it and then it will start the calculation, showing all the intermediate values until it gets to the result.<br/>
For example, if the clock is fed the number 137, it will show: "<b>137</b>" → "<b>11</b>" → "<b>2</b>" and then it will go black, waiting for the next number.</p>
<p>Every digital number consists of some light segments: three horizontal (top, middle, bottom) and four vertical (top-left, top-right, bottom-left, bottom-right).<br/>
Number "<b>1</b>" is made of vertical top-right and bottom-right, number "<b>4</b>" is made by middle horizontal and vertical top-left, top-right and bottom-right. Number "<b>8</b>" lights them all.</p>
<p>The clocks consume energy only when segments are turned on/off.<br/>
To turn on a "<b>2</b>" will cost 5 transitions, while a "<b>7</b>" will cost only 4 transitions.</p>
<p>Sam and Max built two different clocks.</p>
<p>Sam's clock is fed e.g. number 137: the clock shows "<b>137</b>", then the panel is turned off, then the next number ("<b>11</b>") is turned on, then the panel is turned off again and finally the last number ("<b>2</b>") is turned on and, after some time, off.<br/>
For the example, with number 137, Sam's clock requires:<br/></p><table><tr><td>"<b>137</b>"</td>
<td>:</td>
<td>(2 + 5 + 4) × 2 = 22 transitions ("<b>137</b>" on/off).</td>
</tr><tr><td>"<b>11</b>"</td>
<td>:</td>
<td>(2 + 2) × 2 = 8 transitions ("<b>11</b>" on/off).</td>
</tr><tr><td>"<b>2</b>"</td>
<td>:</td>
<td>(5) × 2 = 10 transitions ("<b>2</b>" on/off).</td>
</tr></table>
For a grand total of 40 transitions.
<p>Max's clock works differently. Instead of turning off the whole panel, it is smart enough to turn off only those segments that won't be needed for the next number.<br/>
For number 137, Max's clock requires:<br/></p><table><tr><td>"<b>137</b>"<br/><br/></td>
<td>:<br/><br/></td>
<td>2 + 5 + 4 = 11 transitions ("<b>137</b>" on)<br/>
7 transitions (to turn off the segments that are not needed for number "<b>11</b>").</td>
</tr><tr><td>"<b>11</b>"<br/><br/><br/></td>
<td>:<br/><br/><br/></td>
<td>0 transitions (number "<b>11</b>" is already turned on correctly)<br/>
3 transitions (to turn off the first "<b>1</b>" and the bottom part of the second "<b>1</b>"; <br/>
the top part is common with number "<b>2</b>").</td>
</tr><tr><td>"<b>2</b>"<br/><br/></td>
<td>:<br/><br/></td>
<td>4 transitions (to turn on the remaining segments in order to get a "<b>2</b>")<br/>
5 transitions (to turn off number "<b>2</b>").</td>
</tr></table>
For a grand total of 30 transitions.
<p>Of course, Max's clock consumes less power than Sam's one.<br/>
The two clocks are fed all the prime numbers between A = 10<sup>7</sup> and B = 2×10<sup>7</sup>. <br/>
Find the difference between the total number of transitions needed by Sam's clock and that needed by Max's one.</p> | 13625242 | Sunday, 19th December 2010, 10:00 am | 3692 | 20% | easy |
548 | Gozinta Chains | A gozinta chainfor $n$ is a sequence $\{1,a,b,\dots,n\}$ where each element properly divides the next.
There are eight gozinta chains for $12$:
$\{1,12\}$, $\{1,2,12\}$, $\{1,2,4,12\}$, $\{1,2,6,12\}$, $\{1,3,12\}$, $\{1,3,6,12\}$, $\{1,4,12\}$ and $\{1,6,12\}$.
Let $g(n)$ be the number of gozinta chains for $n$, so $g(12)=8$.
$g(48)=48$ and $g(120)=132$.
Find the sum of the numbers $n$ not exceeding $10^{16}$ for which $g(n)=n$. | A gozinta chainfor $n$ is a sequence $\{1,a,b,\dots,n\}$ where each element properly divides the next.
There are eight gozinta chains for $12$:
$\{1,12\}$, $\{1,2,12\}$, $\{1,2,4,12\}$, $\{1,2,6,12\}$, $\{1,3,12\}$, $\{1,3,6,12\}$, $\{1,4,12\}$ and $\{1,6,12\}$.
Let $g(n)$ be the number of gozinta chains for $n$, so $g(12)=8$.
$g(48)=48$ and $g(120)=132$.
Find the sum of the numbers $n$ not exceeding $10^{16}$ for which $g(n)=n$. | <p>
A <strong>gozinta chain</strong>for $n$ is a sequence $\{1,a,b,\dots,n\}$ where each element properly divides the next.<br/>
There are eight gozinta chains for $12$:<br/>
$\{1,12\}$, $\{1,2,12\}$, $\{1,2,4,12\}$, $\{1,2,6,12\}$, $\{1,3,12\}$, $\{1,3,6,12\}$, $\{1,4,12\}$ and $\{1,6,12\}$.<br/>
Let $g(n)$ be the number of gozinta chains for $n$, so $g(12)=8$.<br/>
$g(48)=48$ and $g(120)=132$.
</p>
<p>
Find the sum of the numbers $n$ not exceeding $10^{16}$ for which $g(n)=n$.
</p> | 12144044603581281 | Sunday, 21st February 2016, 07:00 am | 695 | 35% | medium |
334 | Spilling the Beans | In Plato's heaven, there exist an infinite number of bowls in a straight line.
Each bowl either contains some or none of a finite number of beans.
A child plays a game, which allows only one kind of move: removing two beans from any bowl, and putting one in each of the two adjacent bowls. The game ends when each bowl contains either one or no beans.
For example, consider two adjacent bowls containing $2$ and $3$ beans respectively, all other bowls being empty. The following eight moves will finish the game:
You are given the following sequences:
$\def\htmltext#1{\style{font-family:inherit;}{\text{#1}}}$
$
\begin{align}
\qquad t_0 &= 123456,\cr
\qquad t_i &= \cases{
\;\;\frac{t_{i-1}}{2},&$\htmltext{if }t_{i-1}\htmltext{ is even}$\cr
\left\lfloor\frac{t_{i-1}}{2}\right\rfloor\oplus 926252,&$\htmltext{if }t_{i-1}\htmltext{ is odd}$\cr}\cr
&\qquad\htmltext{where }\lfloor x\rfloor\htmltext{ is the floor function }\cr
&\qquad\!\htmltext{and }\oplus\htmltext{is the bitwise XOR operator.}\cr
\qquad b_i &= (t_i\bmod2^{11}) + 1.\cr
\end{align}
$
The first two terms of the last sequence are $b_1 = 289$ and $b_2 = 145$.
If we start with $b_1$ and $b_2$ beans in two adjacent bowls, $3419100$ moves would be required to finish the game.
Consider now $1500$ adjacent bowls containing $b_1, b_2, \ldots, b_{1500}$ beans respectively, all other bowls being empty. Find how many moves it takes before the game ends. | In Plato's heaven, there exist an infinite number of bowls in a straight line.
Each bowl either contains some or none of a finite number of beans.
A child plays a game, which allows only one kind of move: removing two beans from any bowl, and putting one in each of the two adjacent bowls. The game ends when each bowl contains either one or no beans.
For example, consider two adjacent bowls containing $2$ and $3$ beans respectively, all other bowls being empty. The following eight moves will finish the game:
You are given the following sequences:
$\def\htmltext#1{\style{font-family:inherit;}{\text{#1}}}$
$
\begin{align}
\qquad t_0 &= 123456,\cr
\qquad t_i &= \cases{
\;\;\frac{t_{i-1}}{2},&$\htmltext{if }t_{i-1}\htmltext{ is even}$\cr
\left\lfloor\frac{t_{i-1}}{2}\right\rfloor\oplus 926252,&$\htmltext{if }t_{i-1}\htmltext{ is odd}$\cr}\cr
&\qquad\htmltext{where }\lfloor x\rfloor\htmltext{ is the floor function }\cr
&\qquad\!\htmltext{and }\oplus\htmltext{is the bitwise XOR operator.}\cr
\qquad b_i &= (t_i\bmod2^{11}) + 1.\cr
\end{align}
$
The first two terms of the last sequence are $b_1 = 289$ and $b_2 = 145$.
If we start with $b_1$ and $b_2$ beans in two adjacent bowls, $3419100$ moves would be required to finish the game.
Consider now $1500$ adjacent bowls containing $b_1, b_2, \ldots, b_{1500}$ beans respectively, all other bowls being empty. Find how many moves it takes before the game ends. | <p>In Plato's heaven, there exist an infinite number of bowls in a straight line.<br/>
Each bowl either contains some or none of a finite number of beans.<br/>
A child plays a game, which allows only one kind of move: removing two beans from any bowl, and putting one in each of the two adjacent bowls.<br/> The game ends when each bowl contains either one or no beans.</p>
<p>For example, consider two adjacent bowls containing $2$ and $3$ beans respectively, all other bowls being empty. The following eight moves will finish the game:</p>
<div align="center"><img alt="0334_beans.gif" class="dark_img" src="resources/images/0334_beans.gif?1678992056"/></div>
<p>You are given the following sequences:<br/></p>
<p>
$\def\htmltext#1{\style{font-family:inherit;}{\text{#1}}}$
$
\begin{align}
\qquad t_0 &= 123456,\cr
\qquad t_i &= \cases{
\;\;\frac{t_{i-1}}{2},&$\htmltext{if }t_{i-1}\htmltext{ is even}$\cr
\left\lfloor\frac{t_{i-1}}{2}\right\rfloor\oplus 926252,&$\htmltext{if }t_{i-1}\htmltext{ is odd}$\cr}\cr
&\qquad\htmltext{where }\lfloor x\rfloor\htmltext{ is the floor function }\cr
&\qquad\!\htmltext{and }\oplus\htmltext{is the bitwise XOR operator.}\cr
\qquad b_i &= (t_i\bmod2^{11}) + 1.\cr
\end{align}
$
</p>
<p>The first two terms of the last sequence are $b_1 = 289$ and $b_2 = 145$.<br/>
If we start with $b_1$ and $b_2$ beans in two adjacent bowls, $3419100$ moves would be required to finish the game.</p>
<p>Consider now $1500$ adjacent bowls containing $b_1, b_2, \ldots, b_{1500}$ beans respectively, all other bowls being empty. Find how many moves it takes before the game ends.</p> | 150320021261690835 | Saturday, 23rd April 2011, 04:00 pm | 527 | 65% | hard |
183 | Maximum Product of Parts | Let $N$ be a positive integer and let $N$ be split into $k$ equal parts, $r = N/k$, so that $N = r + r + \cdots + r$.
Let $P$ be the product of these parts, $P = r \times r \times \cdots \times r = r^k$.
For example, if $11$ is split into five equal parts, $11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2$, then $P = 2.2^5 = 51.53632$.
Let $M(N) = P_{\mathrm{max}}$ for a given value of $N$.
It turns out that the maximum for $N = 11$ is found by splitting eleven into four equal parts which leads to $P_{\mathrm{max}} = (11/4)^4$; that is, $M(11) = 14641/256 = 57.19140625$, which is a terminating decimal.
However, for $N = 8$ the maximum is achieved by splitting it into three equal parts, so $M(8) = 512/27$, which is a non-terminating decimal.
Let $D(N) = N$ if $M(N)$ is a non-terminating decimal and $D(N) = -N$ if $M(N)$ is a terminating decimal.
For example, $\sum\limits_{N = 5}^{100} D(N)$ is $2438$.
Find $\sum\limits_{N = 5}^{10000} D(N)$. | Let $N$ be a positive integer and let $N$ be split into $k$ equal parts, $r = N/k$, so that $N = r + r + \cdots + r$.
Let $P$ be the product of these parts, $P = r \times r \times \cdots \times r = r^k$.
For example, if $11$ is split into five equal parts, $11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2$, then $P = 2.2^5 = 51.53632$.
Let $M(N) = P_{\mathrm{max}}$ for a given value of $N$.
It turns out that the maximum for $N = 11$ is found by splitting eleven into four equal parts which leads to $P_{\mathrm{max}} = (11/4)^4$; that is, $M(11) = 14641/256 = 57.19140625$, which is a terminating decimal.
However, for $N = 8$ the maximum is achieved by splitting it into three equal parts, so $M(8) = 512/27$, which is a non-terminating decimal.
Let $D(N) = N$ if $M(N)$ is a non-terminating decimal and $D(N) = -N$ if $M(N)$ is a terminating decimal.
For example, $\sum\limits_{N = 5}^{100} D(N)$ is $2438$.
Find $\sum\limits_{N = 5}^{10000} D(N)$. | <p>Let $N$ be a positive integer and let $N$ be split into $k$ equal parts, $r = N/k$, so that $N = r + r + \cdots + r$.<br/>
Let $P$ be the product of these parts, $P = r \times r \times \cdots \times r = r^k$.</p>
<p>For example, if $11$ is split into five equal parts, $11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2$, then $P = 2.2^5 = 51.53632$.</p>
<p>Let $M(N) = P_{\mathrm{max}}$ for a given value of $N$.</p>
<p>It turns out that the maximum for $N = 11$ is found by splitting eleven into four equal parts which leads to $P_{\mathrm{max}} = (11/4)^4$; that is, $M(11) = 14641/256 = 57.19140625$, which is a terminating decimal.</p>
<p>However, for $N = 8$ the maximum is achieved by splitting it into three equal parts, so $M(8) = 512/27$, which is a non-terminating decimal.</p>
<p>Let $D(N) = N$ if $M(N)$ is a non-terminating decimal and $D(N) = -N$ if $M(N)$ is a terminating decimal.</p>
<p>For example, $\sum\limits_{N = 5}^{100} D(N)$ is $2438$.</p>
<p>Find $\sum\limits_{N = 5}^{10000} D(N)$.</p> | 48861552 | Friday, 22nd February 2008, 05:00 pm | 5136 | 45% | medium |
50 | Consecutive Prime Sum | The prime $41$, can be written as the sum of six consecutive primes:
$$41 = 2 + 3 + 5 + 7 + 11 + 13.$$
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime, contains $21$ terms, and is equal to $953$.
Which prime, below one-million, can be written as the sum of the most consecutive primes? | The prime $41$, can be written as the sum of six consecutive primes:
$$41 = 2 + 3 + 5 + 7 + 11 + 13.$$
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime, contains $21$ terms, and is equal to $953$.
Which prime, below one-million, can be written as the sum of the most consecutive primes? | <p>The prime $41$, can be written as the sum of six consecutive primes:</p>
$$41 = 2 + 3 + 5 + 7 + 11 + 13.$$
<p>This is the longest sum of consecutive primes that adds to a prime below one-hundred.</p>
<p>The longest sum of consecutive primes below one-thousand that adds to a prime, contains $21$ terms, and is equal to $953$.</p>
<p>Which prime, below one-million, can be written as the sum of the most consecutive primes?</p> | 997651 | Friday, 15th August 2003, 06:00 pm | 68636 | 5% | easy |
519 | Tricoloured Coin Fountains | An arrangement of coins in one or more rows with the bottom row being a block without gaps and every coin in a higher row touching exactly two coins in the row below is called a fountain of coins. Let $f(n)$ be the number of possible fountains with $n$ coins. For $4$ coins there are three possible arrangements:
Therefore $f(4) = 3$ while $f(10) = 78$.
Let $T(n)$ be the number of all possible colourings with three colours for all $f(n)$ different fountains with $n$ coins, given the condition that no two touching coins have the same colour. Below you see the possible colourings for one of the three valid fountains for $4$ coins:
You are given that $T(4) = 48$ and $T(10) = 17760$.
Find the last $9$ digits of $T(20000)$. | An arrangement of coins in one or more rows with the bottom row being a block without gaps and every coin in a higher row touching exactly two coins in the row below is called a fountain of coins. Let $f(n)$ be the number of possible fountains with $n$ coins. For $4$ coins there are three possible arrangements:
Therefore $f(4) = 3$ while $f(10) = 78$.
Let $T(n)$ be the number of all possible colourings with three colours for all $f(n)$ different fountains with $n$ coins, given the condition that no two touching coins have the same colour. Below you see the possible colourings for one of the three valid fountains for $4$ coins:
You are given that $T(4) = 48$ and $T(10) = 17760$.
Find the last $9$ digits of $T(20000)$. | <p>An arrangement of coins in one or more rows with the bottom row being a block without gaps and every coin in a higher row touching exactly two coins in the row below is called a <dfn>fountain</dfn> of coins. Let $f(n)$ be the number of possible fountains with $n$ coins. For $4$ coins there are three possible arrangements:</p>
<div align="center"><img alt="0519_coin_fountain.png" src="resources/images/0519_coin_fountain.png?1678992053"/></div>
<p>Therefore $f(4) = 3$ while $f(10) = 78$.</p>
<p>Let $T(n)$ be the number of all possible colourings with three colours for all $f(n)$ different fountains with $n$ coins, given the condition that no two touching coins have the same colour. Below you see the possible colourings for one of the three valid fountains for $4$ coins:</p>
<div align="center"><img alt="0519_tricolored_coin_fountain.png" src="resources/images/0519_tricolored_coin_fountain.png?1678992053"/></div>
<p>You are given that $T(4) = 48$ and $T(10) = 17760$.</p>
<p>Find the last $9$ digits of $T(20000)$.</p> | 804739330 | Saturday, 6th June 2015, 07:00 pm | 375 | 50% | medium |
103 | Special Subset Sums: Optimum | Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true:
$S(B) \ne S(C)$; that is, sums of subsets cannot be equal.
If $B$ contains more elements than $C$ then $S(B) \gt S(C)$.
If $S(A)$ is minimised for a given $n$, we shall call it an optimum special sum set. The first five optimum special sum sets are given below.
$n = 1$: $\{1\}$
$n = 2$: $\{1, 2\}$
$n = 3$: $\{2, 3, 4\}$
$n = 4$: $\{3, 5, 6, 7\}$
$n = 5$: $\{6, 9, 11, 12, 13\}$
It seems that for a given optimum set, $A = \{a_1, a_2, \dots, a_n\}$, the next optimum set is of the form $B = \{b, a_1 + b, a_2 + b, \dots, a_n + b\}$, where $b$ is the "middle" element on the previous row.
By applying this "rule" we would expect the optimum set for $n = 6$ to be $A = \{11, 17, 20, 22, 23, 24\}$, with $S(A) = 117$. However, this is not the optimum set, as we have merely applied an algorithm to provide a near optimum set. The optimum set for $n = 6$ is $A = \{11, 18, 19, 20, 22, 25\}$, with $S(A) = 115$ and corresponding set string: 111819202225.
Given that $A$ is an optimum special sum set for $n = 7$, find its set string.
NOTE: This problem is related to Problem 105 and Problem 106. | Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true:
$S(B) \ne S(C)$; that is, sums of subsets cannot be equal.
If $B$ contains more elements than $C$ then $S(B) \gt S(C)$.
If $S(A)$ is minimised for a given $n$, we shall call it an optimum special sum set. The first five optimum special sum sets are given below.
$n = 1$: $\{1\}$
$n = 2$: $\{1, 2\}$
$n = 3$: $\{2, 3, 4\}$
$n = 4$: $\{3, 5, 6, 7\}$
$n = 5$: $\{6, 9, 11, 12, 13\}$
It seems that for a given optimum set, $A = \{a_1, a_2, \dots, a_n\}$, the next optimum set is of the form $B = \{b, a_1 + b, a_2 + b, \dots, a_n + b\}$, where $b$ is the "middle" element on the previous row.
By applying this "rule" we would expect the optimum set for $n = 6$ to be $A = \{11, 17, 20, 22, 23, 24\}$, with $S(A) = 117$. However, this is not the optimum set, as we have merely applied an algorithm to provide a near optimum set. The optimum set for $n = 6$ is $A = \{11, 18, 19, 20, 22, 25\}$, with $S(A) = 115$ and corresponding set string: 111819202225.
Given that $A$ is an optimum special sum set for $n = 7$, find its set string.
NOTE: This problem is related to Problem 105 and Problem 106. | <p>Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true:</p>
<ol><li>$S(B) \ne S(C)$; that is, sums of subsets cannot be equal.</li>
<li>If $B$ contains more elements than $C$ then $S(B) \gt S(C)$.</li>
</ol><p>If $S(A)$ is minimised for a given $n$, we shall call it an optimum special sum set. The first five optimum special sum sets are given below.</p>
<ul style="list-style-type:none;">
<li>$n = 1$: $\{1\}$</li>
<li>$n = 2$: $\{1, 2\}$</li>
<li>$n = 3$: $\{2, 3, 4\}$</li>
<li>$n = 4$: $\{3, 5, 6, 7\}$</li>
<li>$n = 5$: $\{6, 9, 11, 12, 13\}$</li></ul>
<p>It <i>seems</i> that for a given optimum set, $A = \{a_1, a_2, \dots, a_n\}$, the next optimum set is of the form $B = \{b, a_1 + b, a_2 + b, \dots, a_n + b\}$, where $b$ is the "middle" element on the previous row.</p>
<p>By applying this "rule" we would expect the optimum set for $n = 6$ to be $A = \{11, 17, 20, 22, 23, 24\}$, with $S(A) = 117$. However, this is not the optimum set, as we have merely applied an algorithm to provide a near optimum set. The optimum set for $n = 6$ is $A = \{11, 18, 19, 20, 22, 25\}$, with $S(A) = 115$ and corresponding set string: 111819202225.</p>
<p>Given that $A$ is an optimum special sum set for $n = 7$, find its set string.</p>
<p class="smaller">NOTE: This problem is related to <a href="problem=105">Problem 105</a> and <a href="problem=106">Problem 106</a>.</p> | 20313839404245 | Friday, 26th August 2005, 06:00 pm | 9175 | 45% | medium |
688 | Piles of Plates | We stack $n$ plates into $k$ non-empty piles where each pile is a different size. Define $f(n,k)$ to be the maximum number of plates possible in the smallest pile. For example when $n = 10$ and $k = 3$ the piles $2,3,5$ is the best that can be done and so $f(10,3) = 2$. It is impossible to divide 10 into 5 non-empty differently-sized piles and hence $f(10,5) = 0$.
Define $F(n)$ to be the sum of $f(n,k)$ for all possible pile sizes $k\ge 1$. For example $F(100) = 275$.
Further define $S(N) = \displaystyle\sum_{n=1}^N F(n)$. You are given $S(100) = 12656$.
Find $S(10^{16})$ giving your answer modulo $1\,000\,000\,007$. | We stack $n$ plates into $k$ non-empty piles where each pile is a different size. Define $f(n,k)$ to be the maximum number of plates possible in the smallest pile. For example when $n = 10$ and $k = 3$ the piles $2,3,5$ is the best that can be done and so $f(10,3) = 2$. It is impossible to divide 10 into 5 non-empty differently-sized piles and hence $f(10,5) = 0$.
Define $F(n)$ to be the sum of $f(n,k)$ for all possible pile sizes $k\ge 1$. For example $F(100) = 275$.
Further define $S(N) = \displaystyle\sum_{n=1}^N F(n)$. You are given $S(100) = 12656$.
Find $S(10^{16})$ giving your answer modulo $1\,000\,000\,007$. | <p>
We stack $n$ plates into $k$ non-empty piles where each pile is a different size. Define $f(n,k)$ to be the maximum number of plates possible in the smallest pile. For example when $n = 10$ and $k = 3$ the piles $2,3,5$ is the best that can be done and so $f(10,3) = 2$. It is impossible to divide 10 into 5 non-empty differently-sized piles and hence $f(10,5) = 0$.
</p>
<p>
Define $F(n)$ to be the sum of $f(n,k)$ for all possible pile sizes $k\ge 1$. For example $F(100) = 275$.
</p>
<p>
Further define $S(N) = \displaystyle\sum_{n=1}^N F(n)$. You are given $S(100) = 12656$.
</p>
<p>
Find $S(10^{16})$ giving your answer modulo $1\,000\,000\,007$.
</p> | 110941813 | Sunday, 10th November 2019, 01:00 am | 852 | 20% | easy |
652 | Distinct Values of a Proto-logarithmic Function | Consider the values of $\log_2(8)$, $\log_4(64)$ and $\log_3(27)$. All three are equal to $3$.
Generally, the function $f(m,n)=\log_m(n)$ over integers $m,n \ge 2$ has the property that
$f(m_1,n_1)=f(m_2,n_2)$ if
$\, m_1=a^e, n_1=a^f, m_2=b^e,n_2=b^f \,$ for some integers $a,b,e,f \, \,$ or
$ \, m_1=a^e, n_1=b^e, m_2=a^f,n_2=b^f \,$ for some integers $a,b,e,f \,$
We call a function $g(m,n)$ over integers $m,n \ge 2$ proto-logarithmic if
$\quad \, \, \, \, g(m_1,n_1)=g(m_2,n_2)$ if any integers $a,b,e,f$ fulfilling 1. or 2. can be found
and $\, g(m_1,n_1) \ne g(m_2,n_2)$ if no integers $a,b,e,f$ fulfilling 1. or 2. can be found.
Let $D(N)$ be the number of distinct values that any proto-logarithmic function $g(m,n)$ attains over $2\le m, n\le N$.
For example, $D(5)=13$, $D(10)=69$, $D(100)=9607$ and $D(10000)=99959605$.
Find $D(10^{18})$, and give the last $9$ digits as answer.
Note: According to the four exponentials conjecture the function $\log_m(n)$ is proto-logarithmic. While this conjecture is yet unproven in general, $\log_m(n)$ can be used to calculate $D(N)$ for small values of $N$. | Consider the values of $\log_2(8)$, $\log_4(64)$ and $\log_3(27)$. All three are equal to $3$.
Generally, the function $f(m,n)=\log_m(n)$ over integers $m,n \ge 2$ has the property that
$f(m_1,n_1)=f(m_2,n_2)$ if
$\, m_1=a^e, n_1=a^f, m_2=b^e,n_2=b^f \,$ for some integers $a,b,e,f \, \,$ or
$ \, m_1=a^e, n_1=b^e, m_2=a^f,n_2=b^f \,$ for some integers $a,b,e,f \,$
We call a function $g(m,n)$ over integers $m,n \ge 2$ proto-logarithmic if
$\quad \, \, \, \, g(m_1,n_1)=g(m_2,n_2)$ if any integers $a,b,e,f$ fulfilling 1. or 2. can be found
and $\, g(m_1,n_1) \ne g(m_2,n_2)$ if no integers $a,b,e,f$ fulfilling 1. or 2. can be found.
Let $D(N)$ be the number of distinct values that any proto-logarithmic function $g(m,n)$ attains over $2\le m, n\le N$.
For example, $D(5)=13$, $D(10)=69$, $D(100)=9607$ and $D(10000)=99959605$.
Find $D(10^{18})$, and give the last $9$ digits as answer.
Note: According to the four exponentials conjecture the function $\log_m(n)$ is proto-logarithmic. While this conjecture is yet unproven in general, $\log_m(n)$ can be used to calculate $D(N)$ for small values of $N$. | <p>Consider the values of $\log_2(8)$, $\log_4(64)$ and $\log_3(27)$. All three are equal to $3$.</p>
<p>Generally, the function $f(m,n)=\log_m(n)$ over integers $m,n \ge 2$ has the property that <br/>
$f(m_1,n_1)=f(m_2,n_2)$ if
</p><ol>
<li>$\, m_1=a^e, n_1=a^f, m_2=b^e,n_2=b^f \,$ for some integers $a,b,e,f \, \,$ or </li>
<li> $ \, m_1=a^e, n_1=b^e, m_2=a^f,n_2=b^f \,$ for some integers $a,b,e,f \,$ </li></ol>
<p>We call a function $g(m,n)$ over integers $m,n \ge 2$ <dfn>proto-logarithmic</dfn> if
</p><ul><li>$\quad \, \, \, \, g(m_1,n_1)=g(m_2,n_2)$ if any integers $a,b,e,f$ fulfilling 1. or 2. can be found</li>
<li><b>and</b> $\, g(m_1,n_1) \ne g(m_2,n_2)$ if no integers $a,b,e,f$ fulfilling 1. or 2. can be found.</li>
</ul>
<p>Let $D(N)$ be the number of distinct values that any proto-logarithmic function $g(m,n)$ attains over $2\le m, n\le N$.<br/>
For example, $D(5)=13$, $D(10)=69$, $D(100)=9607$ and $D(10000)=99959605$.</p>
<p>Find $D(10^{18})$, and give the last $9$ digits as answer.</p>
<p><br/>
<font size="2"><b>Note:</b> According to the <strong>four exponentials conjecture</strong> the function $\log_m(n)$ is <dfn>proto-logarithmic</dfn>.<br/> While this conjecture is yet unproven in general, $\log_m(n)$ can be used to calculate $D(N)$ for small values of $N$.</font></p> | 983924497 | Saturday, 19th January 2019, 10:00 pm | 183 | 70% | hard |
42 | Coded Triangle Numbers | The $n$th term of the sequence of triangle numbers is given by, $t_n = \frac12n(n+1)$; so the first ten triangle numbers are:
$$1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \dots$$
By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word value for SKY is $19 + 11 + 25 = 55 = t_{10}$. If the word value is a triangle number then we shall call the word a triangle word.
Using words.txt (right click and 'Save Link/Target As...'), a 16K text file containing nearly two-thousand common English words, how many are triangle words? | The $n$th term of the sequence of triangle numbers is given by, $t_n = \frac12n(n+1)$; so the first ten triangle numbers are:
$$1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \dots$$
By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word value for SKY is $19 + 11 + 25 = 55 = t_{10}$. If the word value is a triangle number then we shall call the word a triangle word.
Using words.txt (right click and 'Save Link/Target As...'), a 16K text file containing nearly two-thousand common English words, how many are triangle words? | <p>The $n$<sup>th</sup> term of the sequence of triangle numbers is given by, $t_n = \frac12n(n+1)$; so the first ten triangle numbers are:
$$1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \dots$$</p>
<p>By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word value for SKY is $19 + 11 + 25 = 55 = t_{10}$. If the word value is a triangle number then we shall call the word a triangle word.</p>
<p>Using <a href="resources/documents/0042_words.txt">words.txt</a> (right click and 'Save Link/Target As...'), a 16K text file containing nearly two-thousand common English words, how many are triangle words?</p> | 162 | Friday, 25th April 2003, 06:00 pm | 80972 | 5% | easy |
554 | Centaurs on a Chess Board | On a chess board, a centaur moves like a king or a knight. The diagram below shows the valid moves of a centaur (represented by an inverted king) on an $8 \times 8$ board.
It can be shown that at most $n^2$ non-attacking centaurs can be placed on a board of size $2n \times 2n$.
Let $C(n)$ be the number of ways to place $n^2$ centaurs on a $2n \times 2n$ board so that no centaur attacks another directly.
For example $C(1) = 4$, $C(2) = 25$, $C(10) = 1477721$.
Let $F_i$ be the $i$th Fibonacci number defined as $F_1 = F_2 = 1$ and $F_i = F_{i - 1} + F_{i - 2}$ for $i \gt 2$.
Find $\displaystyle \left( \sum_{i=2}^{90} C(F_i) \right) \bmod (10^8+7)$. | On a chess board, a centaur moves like a king or a knight. The diagram below shows the valid moves of a centaur (represented by an inverted king) on an $8 \times 8$ board.
It can be shown that at most $n^2$ non-attacking centaurs can be placed on a board of size $2n \times 2n$.
Let $C(n)$ be the number of ways to place $n^2$ centaurs on a $2n \times 2n$ board so that no centaur attacks another directly.
For example $C(1) = 4$, $C(2) = 25$, $C(10) = 1477721$.
Let $F_i$ be the $i$th Fibonacci number defined as $F_1 = F_2 = 1$ and $F_i = F_{i - 1} + F_{i - 2}$ for $i \gt 2$.
Find $\displaystyle \left( \sum_{i=2}^{90} C(F_i) \right) \bmod (10^8+7)$. | <p>On a chess board, a centaur moves like a king or a knight. The diagram below shows the valid moves of a centaur (represented by an inverted king) on an $8 \times 8$ board.</p>
<div align="center"><img alt="0554-centaurs.png" src="resources/images/0554-centaurs.png?1678992053"/></div>
<p>It can be shown that at most $n^2$ non-attacking centaurs can be placed on a board of size $2n \times 2n$.<br/>
Let $C(n)$ be the number of ways to place $n^2$ centaurs on a $2n \times 2n$ board so that no centaur attacks another directly.<br/>
For example $C(1) = 4$, $C(2) = 25$, $C(10) = 1477721$.</p>
<p>Let $F_i$ be the $i$<sup>th</sup> Fibonacci number defined as $F_1 = F_2 = 1$ and $F_i = F_{i - 1} + F_{i - 2}$ for $i \gt 2$.</p>
<p>Find $\displaystyle \left( \sum_{i=2}^{90} C(F_i) \right) \bmod (10^8+7)$.</p> | 89539872 | Sunday, 3rd April 2016, 01:00 am | 277 | 80% | hard |
367 | Bozo Sort | Bozo sort, not to be confused with the slightly less efficient bogo sort, consists out of checking if the input sequence is sorted and if not swapping randomly two elements. This is repeated until eventually the sequence is sorted.
If we consider all permutations of the first $4$ natural numbers as input the expectation value of the number of swaps, averaged over all $4!$ input sequences is $24.75$.
The already sorted sequence takes $0$ steps.
In this problem we consider the following variant on bozo sort.
If the sequence is not in order we pick three elements at random and shuffle these three elements randomly.
All $3!=6$ permutations of those three elements are equally likely.
The already sorted sequence will take $0$ steps.
If we consider all permutations of the first $4$ natural numbers as input the expectation value of the number of shuffles, averaged over all $4!$ input sequences is $27.5$.
Consider as input sequences the permutations of the first $11$ natural numbers.
Averaged over all $11!$ input sequences, what is the expected number of shuffles this sorting algorithm will perform?
Give your answer rounded to the nearest integer. | Bozo sort, not to be confused with the slightly less efficient bogo sort, consists out of checking if the input sequence is sorted and if not swapping randomly two elements. This is repeated until eventually the sequence is sorted.
If we consider all permutations of the first $4$ natural numbers as input the expectation value of the number of swaps, averaged over all $4!$ input sequences is $24.75$.
The already sorted sequence takes $0$ steps.
In this problem we consider the following variant on bozo sort.
If the sequence is not in order we pick three elements at random and shuffle these three elements randomly.
All $3!=6$ permutations of those three elements are equally likely.
The already sorted sequence will take $0$ steps.
If we consider all permutations of the first $4$ natural numbers as input the expectation value of the number of shuffles, averaged over all $4!$ input sequences is $27.5$.
Consider as input sequences the permutations of the first $11$ natural numbers.
Averaged over all $11!$ input sequences, what is the expected number of shuffles this sorting algorithm will perform?
Give your answer rounded to the nearest integer. | <p>
<strong>Bozo sort</strong>, not to be confused with the slightly less efficient <strong>bogo sort</strong>, consists out of checking if the input sequence is sorted and if not swapping randomly two elements. This is repeated until eventually the sequence is sorted.
</p>
<p>
If we consider all permutations of the first $4$ natural numbers as input the expectation value of the number of swaps, averaged over all $4!$ input sequences is $24.75$.<br/>
The already sorted sequence takes $0$ steps.
</p>
<p>
In this problem we consider the following variant on bozo sort.<br/>
If the sequence is not in order we pick three elements at random and shuffle these three elements randomly.<br/>
All $3!=6$ permutations of those three elements are equally likely. <br/>
The already sorted sequence will take $0$ steps.<br/>
If we consider all permutations of the first $4$ natural numbers as input the expectation value of the number of shuffles, averaged over all $4!$ input sequences is $27.5$. <br/>
Consider as input sequences the permutations of the first $11$ natural numbers.<br/>
Averaged over all $11!$ input sequences, what is the expected number of shuffles this sorting algorithm will perform?
</p>
<p>
Give your answer rounded to the nearest integer.
</p> | 48271207 | Saturday, 14th January 2012, 10:00 pm | 577 | 55% | medium |
535 | Fractal Sequence | Consider the infinite integer sequence S starting with:
$S = 1, 1, 2, 1, 3, 2, 4, 1, 5, 3, 6, 2, 7, 8, 4, 9, 1, 10, 11, 5, \dots$
Circle the first occurrence of each integer.
$S = \enclose{circle}1, 1, \enclose{circle}2, 1, \enclose{circle}3, 2, \enclose{circle}4, 1, \enclose{circle}5, 3, \enclose{circle}6, 2, \enclose{circle}7, \enclose{circle}8, 4, \enclose{circle}9, 1, \enclose{circle}{10}, \enclose{circle}{11}, 5, \dots$
The sequence is characterized by the following properties:
The circled numbers are consecutive integers starting with $1$.
Immediately preceding each non-circled numbers $a_i$, there are exactly $\lfloor \sqrt{a_i} \rfloor$ adjacent circled numbers, where $\lfloor\,\rfloor$ is the floor function.
If we remove all circled numbers, the remaining numbers form a sequence identical to $S$, so $S$ is a fractal sequence.
Let $T(n)$ be the sum of the first $n$ elements of the sequence.
You are given $T(1) = 1$, $T(20) = 86$, $T(10^3) = 364089$ and $T(10^9) = 498676527978348241$.
Find $T(10^{18})$. Give the last $9$ digits of your answer. | Consider the infinite integer sequence S starting with:
$S = 1, 1, 2, 1, 3, 2, 4, 1, 5, 3, 6, 2, 7, 8, 4, 9, 1, 10, 11, 5, \dots$
Circle the first occurrence of each integer.
$S = \enclose{circle}1, 1, \enclose{circle}2, 1, \enclose{circle}3, 2, \enclose{circle}4, 1, \enclose{circle}5, 3, \enclose{circle}6, 2, \enclose{circle}7, \enclose{circle}8, 4, \enclose{circle}9, 1, \enclose{circle}{10}, \enclose{circle}{11}, 5, \dots$
The sequence is characterized by the following properties:
The circled numbers are consecutive integers starting with $1$.
Immediately preceding each non-circled numbers $a_i$, there are exactly $\lfloor \sqrt{a_i} \rfloor$ adjacent circled numbers, where $\lfloor\,\rfloor$ is the floor function.
If we remove all circled numbers, the remaining numbers form a sequence identical to $S$, so $S$ is a fractal sequence.
Let $T(n)$ be the sum of the first $n$ elements of the sequence.
You are given $T(1) = 1$, $T(20) = 86$, $T(10^3) = 364089$ and $T(10^9) = 498676527978348241$.
Find $T(10^{18})$. Give the last $9$ digits of your answer. | <p>Consider the infinite integer sequence S starting with:<br/>
$S = 1, 1, 2, 1, 3, 2, 4, 1, 5, 3, 6, 2, 7, 8, 4, 9, 1, 10, 11, 5, \dots$</p>
<p>Circle the first occurrence of each integer.<br/>
$S = \enclose{circle}1, 1, \enclose{circle}2, 1, \enclose{circle}3, 2, \enclose{circle}4, 1, \enclose{circle}5, 3, \enclose{circle}6, 2, \enclose{circle}7, \enclose{circle}8, 4, \enclose{circle}9, 1, \enclose{circle}{10}, \enclose{circle}{11}, 5, \dots$</p>
<p>The sequence is characterized by the following properties:</p>
<ul><li>The circled numbers are consecutive integers starting with $1$.</li>
<li>Immediately preceding each non-circled numbers $a_i$, there are exactly $\lfloor \sqrt{a_i} \rfloor$ adjacent circled numbers, where $\lfloor\,\rfloor$ is the floor function.</li>
<li>If we remove all circled numbers, the remaining numbers form a sequence identical to $S$, so $S$ is a <strong>fractal sequence</strong>.</li></ul>
<p>Let $T(n)$ be the sum of the first $n$ elements of the sequence.<br/>
You are given $T(1) = 1$, $T(20) = 86$, $T(10^3) = 364089$ and $T(10^9) = 498676527978348241$.</p>
<p>Find $T(10^{18})$. Give the last $9$ digits of your answer.</p> | 611778217 | Saturday, 21st November 2015, 04:00 pm | 314 | 60% | hard |
276 | Primitive Triangles | Consider the triangles with integer sides $a$, $b$ and $c$ with $a \le b \le c$.
An integer sided triangle $(a,b,c)$ is called primitive if $\gcd(a, b, c)$$\gcd(a,b,c)=\gcd(a,\gcd(b,c))$$=1$.
How many primitive integer sided triangles exist with a perimeter not exceeding $10\,000\,000$? | Consider the triangles with integer sides $a$, $b$ and $c$ with $a \le b \le c$.
An integer sided triangle $(a,b,c)$ is called primitive if $\gcd(a, b, c)$$\gcd(a,b,c)=\gcd(a,\gcd(b,c))$$=1$.
How many primitive integer sided triangles exist with a perimeter not exceeding $10\,000\,000$? | <p>Consider the triangles with integer sides $a$, $b$ and $c$ with $a \le b \le c$.<br/>
An integer sided triangle $(a,b,c)$ is called primitive if <strong class="tooltip">$\gcd(a, b, c)$<span class="tooltiptext">$\gcd(a,b,c)=\gcd(a,\gcd(b,c))$</span></strong>$=1$. <br/>
How many primitive integer sided triangles exist with a perimeter not exceeding $10\,000\,000$?
</p> | 5777137137739632912 | Friday, 29th January 2010, 09:00 pm | 1209 | 75% | hard |
676 | Matching Digit Sums | Let $d(i,b)$ be the digit sum of the number $i$ in base $b$. For example $d(9,2)=2$, since $9=1001_2$.
When using different bases, the respective digit sums most of the time deviate from each other, for example $d(9,4)=3 \ne d(9,2)$.
However, for some numbers $i$ there will be a match, like $d(17,4)=d(17,2)=2$.
Let $ M(n,b_1,b_2)$ be the sum of all natural numbers $i \le n$ for which $d(i,b_1)=d(i,b_2)$.
For example, $M(10,8,2)=18$, $M(100,8,2)=292$ and $M(10^6,8,2)=19173952$.
Find $\displaystyle \sum_{k=3}^6 \sum_{l=1}^{k-2}M(10^{16},2^k,2^l)$, giving the last $16$ digits as the answer. | Let $d(i,b)$ be the digit sum of the number $i$ in base $b$. For example $d(9,2)=2$, since $9=1001_2$.
When using different bases, the respective digit sums most of the time deviate from each other, for example $d(9,4)=3 \ne d(9,2)$.
However, for some numbers $i$ there will be a match, like $d(17,4)=d(17,2)=2$.
Let $ M(n,b_1,b_2)$ be the sum of all natural numbers $i \le n$ for which $d(i,b_1)=d(i,b_2)$.
For example, $M(10,8,2)=18$, $M(100,8,2)=292$ and $M(10^6,8,2)=19173952$.
Find $\displaystyle \sum_{k=3}^6 \sum_{l=1}^{k-2}M(10^{16},2^k,2^l)$, giving the last $16$ digits as the answer. | <p>
Let $d(i,b)$ be the <strong>digit sum</strong> of the number $i$ in base $b$. For example $d(9,2)=2$, since $9=1001_2$.
When using different bases, the respective digit sums most of the time deviate from each other, for example $d(9,4)=3 \ne d(9,2)$.
</p>
<p>
However, for some numbers $i$ there will be a match, like $d(17,4)=d(17,2)=2$.
Let $ M(n,b_1,b_2)$ be the sum of all natural numbers $i \le n$ for which $d(i,b_1)=d(i,b_2)$.
For example, $M(10,8,2)=18$, $M(100,8,2)=292$ and $M(10^6,8,2)=19173952$.
</p>
<p>
Find $\displaystyle \sum_{k=3}^6 \sum_{l=1}^{k-2}M(10^{16},2^k,2^l)$, giving the last $16$ digits as the answer.
</p> | 3562668074339584 | Saturday, 22nd June 2019, 04:00 pm | 257 | 50% | medium |
833 | Square Triangle Products | Triangle numbers $T_k$ are integers of the form $\frac{k(k+1)} 2$.
A few triangle numbers happen to be perfect squares like $T_1=1$ and $T_8=36$, but more can be found when considering the product of two triangle numbers. For example, $T_2 \cdot T_{24}=3 \cdot 300=30^2$.
Let $S(n)$ be the sum of $c$ for all integers triples $(a, b, c)$ with $0<c \le n$, $c^2=T_a \cdot T_b$ and $0<a<b$.
For example, $S(100)= \sqrt{T_1 T_8}+\sqrt{T_2 T_{24}}+\sqrt{T_1 T_{49}}+\sqrt{T_3 T_{48}}=6+30+35+84=155$.
You are given $S(10^5)=1479802$ and $S(10^9)=241614948794$.
Find $S(10^{35})$. Give your answer modulo $136101521$. | Triangle numbers $T_k$ are integers of the form $\frac{k(k+1)} 2$.
A few triangle numbers happen to be perfect squares like $T_1=1$ and $T_8=36$, but more can be found when considering the product of two triangle numbers. For example, $T_2 \cdot T_{24}=3 \cdot 300=30^2$.
Let $S(n)$ be the sum of $c$ for all integers triples $(a, b, c)$ with $0<c \le n$, $c^2=T_a \cdot T_b$ and $0<a<b$.
For example, $S(100)= \sqrt{T_1 T_8}+\sqrt{T_2 T_{24}}+\sqrt{T_1 T_{49}}+\sqrt{T_3 T_{48}}=6+30+35+84=155$.
You are given $S(10^5)=1479802$ and $S(10^9)=241614948794$.
Find $S(10^{35})$. Give your answer modulo $136101521$. | <p>Triangle numbers $T_k$ are integers of the form $\frac{k(k+1)} 2$.<br/>
A few triangle numbers happen to be perfect squares like $T_1=1$ and $T_8=36$, but more can be found when considering the product of two triangle numbers. For example, $T_2 \cdot T_{24}=3 \cdot 300=30^2$.</p>
<p>Let $S(n)$ be the sum of $c$ for all integers triples $(a, b, c)$ with $0<c \le n$, $c^2=T_a \cdot T_b$ and $0<a<b$.
For example, $S(100)= \sqrt{T_1 T_8}+\sqrt{T_2 T_{24}}+\sqrt{T_1 T_{49}}+\sqrt{T_3 T_{48}}=6+30+35+84=155$.</p>
<p>
You are given $S(10^5)=1479802$ and $S(10^9)=241614948794$.</p>
<p>
Find $S(10^{35})$. Give your answer modulo $136101521$.</p> | 43884302 | Sunday, 12th March 2023, 07:00 am | 178 | 65% | hard |
304 | Primonacci | For any positive integer $n$ the function $\operatorname{next\_prime}(n)$ returns the smallest prime $p$ such that $p \gt n$.
The sequence $a(n)$ is defined by:
$a(1)=\operatorname{next\_prime}(10^{14})$ and $a(n)=\operatorname{next\_prime}(a(n-1))$ for $n \gt 1$.
The Fibonacci sequence $f(n)$ is defined by:
$f(0)=0$, $f(1)=1$ and $f(n)=f(n-1)+f(n-2)$ for $n \gt 1$.
The sequence $b(n)$ is defined as $f(a(n))$.
Find $\sum b(n)$ for $1 \le n \le 100\,000$.
Give your answer mod $1234567891011$. | For any positive integer $n$ the function $\operatorname{next\_prime}(n)$ returns the smallest prime $p$ such that $p \gt n$.
The sequence $a(n)$ is defined by:
$a(1)=\operatorname{next\_prime}(10^{14})$ and $a(n)=\operatorname{next\_prime}(a(n-1))$ for $n \gt 1$.
The Fibonacci sequence $f(n)$ is defined by:
$f(0)=0$, $f(1)=1$ and $f(n)=f(n-1)+f(n-2)$ for $n \gt 1$.
The sequence $b(n)$ is defined as $f(a(n))$.
Find $\sum b(n)$ for $1 \le n \le 100\,000$.
Give your answer mod $1234567891011$. | <p>
For any positive integer $n$ the function $\operatorname{next\_prime}(n)$ returns the smallest prime $p$ such that $p \gt n$.
</p>
<p>
The sequence $a(n)$ is defined by:<br/>
$a(1)=\operatorname{next\_prime}(10^{14})$ and $a(n)=\operatorname{next\_prime}(a(n-1))$ for $n \gt 1$.
</p>
<p>
The Fibonacci sequence $f(n)$ is defined by:
$f(0)=0$, $f(1)=1$ and $f(n)=f(n-1)+f(n-2)$ for $n \gt 1$.
</p>
<p>
The sequence $b(n)$ is defined as $f(a(n))$.
</p>
<p>
Find $\sum b(n)$ for $1 \le n \le 100\,000$.
Give your answer mod $1234567891011$.
</p> | 283988410192 | Sunday, 3rd October 2010, 01:00 am | 2437 | 40% | medium |
114 | Counting Block Combinations I | A row measuring seven units in length has red blocks with a minimum length of three units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one grey square. There are exactly seventeen ways of doing this.
How many ways can a row measuring fifty units in length be filled?
NOTE: Although the example above does not lend itself to the possibility, in general it is permitted to mix block sizes. For example, on a row measuring eight units in length you could use red (3), grey (1), and red (4). | A row measuring seven units in length has red blocks with a minimum length of three units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one grey square. There are exactly seventeen ways of doing this.
How many ways can a row measuring fifty units in length be filled?
NOTE: Although the example above does not lend itself to the possibility, in general it is permitted to mix block sizes. For example, on a row measuring eight units in length you could use red (3), grey (1), and red (4). | <p>A row measuring seven units in length has red blocks with a minimum length of three units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one grey square. There are exactly seventeen ways of doing this.</p>
<div class="center">
<img alt="0114.png" src="resources/images/0114.png?1678992052"/>
</div>
<p>How many ways can a row measuring fifty units in length be filled?</p>
<p class="note">NOTE: Although the example above does not lend itself to the possibility, in general it is permitted to mix block sizes. For example, on a row measuring eight units in length you could use red (3), grey (1), and red (4).</p> | 16475640049 | Friday, 17th February 2006, 06:00 pm | 12093 | 35% | medium |
750 | Optimal Card Stacking | Card Stacking is a game on a computer starting with an array of $N$ cards labelled $1,2,\ldots,N$.
A stack of cards can be moved by dragging horizontally with the mouse to another stack but only when the resulting stack is in sequence. The goal of the game is to combine the cards into a single stack using minimal total drag distance.
For the given arrangement of 6 cards the minimum total distance is $1 + 3 + 1 + 1 + 2 = 8$.
For $N$ cards, the cards are arranged so that the card at position $n$ is $3^n\bmod(N+1), 1\le n\le N$.
We define $G(N)$ to be the minimal total drag distance to arrange these cards into a single sequence.
For example, when $N = 6$ we get the sequence $3,2,6,4,5,1$ and $G(6) = 8$.
You are given $G(16) = 47$.
Find $G(976)$.
Note: $G(N)$ is not defined for all values of $N$. | Card Stacking is a game on a computer starting with an array of $N$ cards labelled $1,2,\ldots,N$.
A stack of cards can be moved by dragging horizontally with the mouse to another stack but only when the resulting stack is in sequence. The goal of the game is to combine the cards into a single stack using minimal total drag distance.
For the given arrangement of 6 cards the minimum total distance is $1 + 3 + 1 + 1 + 2 = 8$.
For $N$ cards, the cards are arranged so that the card at position $n$ is $3^n\bmod(N+1), 1\le n\le N$.
We define $G(N)$ to be the minimal total drag distance to arrange these cards into a single sequence.
For example, when $N = 6$ we get the sequence $3,2,6,4,5,1$ and $G(6) = 8$.
You are given $G(16) = 47$.
Find $G(976)$.
Note: $G(N)$ is not defined for all values of $N$. | <p>
Card Stacking is a game on a computer starting with an array of $N$ cards labelled $1,2,\ldots,N$.
A stack of cards can be moved by dragging horizontally with the mouse to another stack but only when the resulting stack is in sequence. The goal of the game is to combine the cards into a single stack using minimal total drag distance.
</p>
<div style="text-align:center;">
<img alt="" class="dark_img" src="project/images/p750_optimal_card_stacking.png"/></div>
<p>
For the given arrangement of 6 cards the minimum total distance is $1 + 3 + 1 + 1 + 2 = 8$.
</p>
<p>
For $N$ cards, the cards are arranged so that the card at position $n$ is $3^n\bmod(N+1), 1\le n\le N$.
</p>
<p>
We define $G(N)$ to be the minimal total drag distance to arrange these cards into a single sequence.<br>
For example, when $N = 6$ we get the sequence $3,2,6,4,5,1$ and $G(6) = 8$.<br/>
You are given $G(16) = 47$.
</br></p>
<p>
Find $G(976)$.
</p>
<p>
Note: $G(N)$ is not defined for all values of $N$.
</p> | 160640 | Saturday, 6th March 2021, 07:00 pm | 354 | 35% | medium |
918 | Recursive Sequence Summation | The sequence $a_n$ is defined by $a_1=1$, and then recursively for $n\geq1$:
\begin{align*}
a_{2n} &=2a_n\\
a_{2n+1} &=a_n-3a_{n+1}
\end{align*}
The first ten terms are $1, 2, -5, 4, 17, -10, -17, 8, -47, 34$.
Define $\displaystyle S(N) = \sum_{n=1}^N a_n$. You are given $S(10) = -13$
Find $S(10^{12})$. | The sequence $a_n$ is defined by $a_1=1$, and then recursively for $n\geq1$:
\begin{align*}
a_{2n} &=2a_n\\
a_{2n+1} &=a_n-3a_{n+1}
\end{align*}
The first ten terms are $1, 2, -5, 4, 17, -10, -17, 8, -47, 34$.
Define $\displaystyle S(N) = \sum_{n=1}^N a_n$. You are given $S(10) = -13$
Find $S(10^{12})$. | <p>
The sequence $a_n$ is defined by $a_1=1$, and then recursively for $n\geq1$:
\begin{align*}
a_{2n} &=2a_n\\
a_{2n+1} &=a_n-3a_{n+1}
\end{align*}
The first ten terms are $1, 2, -5, 4, 17, -10, -17, 8, -47, 34$.<br/>
Define $\displaystyle S(N) = \sum_{n=1}^N a_n$. You are given $S(10) = -13$<br/>
Find $S(10^{12})$.
</p> | -6999033352333308 | Sunday, 24th November 2024, 04:00 am | 931 | 10% | easy |
438 | Integer Part of Polynomial Equation's Solutions | For an $n$-tuple of integers $t = (a_1, \dots, a_n)$, let $(x_1, \dots, x_n)$ be the solutions of the polynomial equation $x^n + a_1 x^{n-1} + a_2 x^{n-2} + \cdots + a_{n-1}x + a_n = 0$.
Consider the following two conditions:
$x_1, \dots, x_n$ are all real.
If $x_1, \dots, x_n$ are sorted, $\lfloor x_i\rfloor = i$ for $1 \leq i \leq n$. ($\lfloor \cdot \rfloor$: floor function.)
In the case of $n = 4$, there are $12$ $n$-tuples of integers which satisfy both conditions.
We define $S(t)$ as the sum of the absolute values of the integers in $t$.
For $n = 4$ we can verify that $\sum S(t) = 2087$ for all $n$-tuples $t$ which satisfy both conditions.
Find $\sum S(t)$ for $n = 7$. | For an $n$-tuple of integers $t = (a_1, \dots, a_n)$, let $(x_1, \dots, x_n)$ be the solutions of the polynomial equation $x^n + a_1 x^{n-1} + a_2 x^{n-2} + \cdots + a_{n-1}x + a_n = 0$.
Consider the following two conditions:
$x_1, \dots, x_n$ are all real.
If $x_1, \dots, x_n$ are sorted, $\lfloor x_i\rfloor = i$ for $1 \leq i \leq n$. ($\lfloor \cdot \rfloor$: floor function.)
In the case of $n = 4$, there are $12$ $n$-tuples of integers which satisfy both conditions.
We define $S(t)$ as the sum of the absolute values of the integers in $t$.
For $n = 4$ we can verify that $\sum S(t) = 2087$ for all $n$-tuples $t$ which satisfy both conditions.
Find $\sum S(t)$ for $n = 7$. | <p>
For an $n$-tuple of integers $t = (a_1, \dots, a_n)$, let $(x_1, \dots, x_n)$ be the solutions of the polynomial equation $x^n + a_1 x^{n-1} + a_2 x^{n-2} + \cdots + a_{n-1}x + a_n = 0$.
</p>
<p>
Consider the following two conditions:
</p><ul><li>$x_1, \dots, x_n$ are all real.
</li><li>If $x_1, \dots, x_n$ are sorted, $\lfloor x_i\rfloor = i$ for $1 \leq i \leq n$. ($\lfloor \cdot \rfloor$: floor function.)
</li></ul><p>
In the case of $n = 4$, there are $12$ $n$-tuples of integers which satisfy both conditions.<br/>
We define $S(t)$ as the sum of the absolute values of the integers in $t$.<br/>
For $n = 4$ we can verify that $\sum S(t) = 2087$ for all $n$-tuples $t$ which satisfy both conditions.
</p>
<p>
Find $\sum S(t)$ for $n = 7$.
</p> | 2046409616809 | Sunday, 29th September 2013, 01:00 am | 302 | 95% | hard |
492 | Exploding Sequence | Define the sequence $a_1, a_2, a_3, \dots$ as:
$a_1 = 1$
$a_{n+1} = 6a_n^2 + 10a_n + 3$ for $n \ge 1$.
Examples:
$a_3 = 2359$
$a_6 = 269221280981320216750489044576319$
$a_6 \bmod 1\,000\,000\,007 = 203064689$
$a_{100} \bmod 1\,000\,000\,007 = 456482974$
Define $B(x,y,n)$ as $\sum (a_n \bmod p)$ for every prime $p$ such that $x \le p \le x+y$.
Examples:
$B(10^9, 10^3, 10^3) = 23674718882$
$B(10^9, 10^3, 10^{15}) = 20731563854$
Find $B(10^9, 10^7, 10^{15})$. | Define the sequence $a_1, a_2, a_3, \dots$ as:
$a_1 = 1$
$a_{n+1} = 6a_n^2 + 10a_n + 3$ for $n \ge 1$.
Examples:
$a_3 = 2359$
$a_6 = 269221280981320216750489044576319$
$a_6 \bmod 1\,000\,000\,007 = 203064689$
$a_{100} \bmod 1\,000\,000\,007 = 456482974$
Define $B(x,y,n)$ as $\sum (a_n \bmod p)$ for every prime $p$ such that $x \le p \le x+y$.
Examples:
$B(10^9, 10^3, 10^3) = 23674718882$
$B(10^9, 10^3, 10^{15}) = 20731563854$
Find $B(10^9, 10^7, 10^{15})$. | <p>Define the sequence $a_1, a_2, a_3, \dots$ as:</p>
<ul><li>$a_1 = 1$</li>
<li>$a_{n+1} = 6a_n^2 + 10a_n + 3$ for $n \ge 1$.</li>
</ul><p>
Examples:<br/>
$a_3 = 2359$<br/>
$a_6 = 269221280981320216750489044576319$<br/>
$a_6 \bmod 1\,000\,000\,007 = 203064689$<br/>
$a_{100} \bmod 1\,000\,000\,007 = 456482974$
</p>
<p>
Define $B(x,y,n)$ as $\sum (a_n \bmod p)$ for every prime $p$ such that $x \le p \le x+y$.
</p>
<p>
Examples:<br/>
$B(10^9, 10^3, 10^3) = 23674718882$<br/>
$B(10^9, 10^3, 10^{15}) = 20731563854$
</p>
<p>Find $B(10^9, 10^7, 10^{15})$.</p> | 242586962923928 | Saturday, 6th December 2014, 01:00 pm | 399 | 60% | hard |
527 | Randomized Binary Search | A secret integer $t$ is selected at random within the range $1 \le t \le n$.
The goal is to guess the value of $t$ by making repeated guesses, via integer $g$. After a guess is made, there are three possible outcomes, in which it will be revealed that either $g \lt t$, $g = t$, or $g \gt t$. Then the process can repeat as necessary.
Normally, the number of guesses required on average can be minimized with a binary search: Given a lower bound $L$ and upper bound $H$ (initialized to $L = 1$ and $H = n$), let $g = \lfloor(L+H)/2\rfloor$ where $\lfloor \cdot \rfloor$ is the integer floor function. If $g = t$, the process ends. Otherwise, if $g \lt t$, set $L = g+1$, but if $g \gt t$ instead, set $H = g - 1$. After setting the new bounds, the search process repeats, and ultimately ends once $t$ is found. Even if $t$ can be deduced without searching, assume that a search will be required anyway to confirm the value.
Your friend Bob believes that the standard binary search is not that much better than his randomized variant: Instead of setting $g = \lfloor(L+H)/2\rfloor$, simply let $g$ be a random integer between $L$ and $H$, inclusive. The rest of the algorithm is the same as the standard binary search. This new search routine will be referred to as a random binary search.
Given that $1 \le t \le n$ for random $t$, let $B(n)$ be the expected number of guesses needed to find $t$ using the standard binary search, and let $R(n)$ be the expected number of guesses needed to find $t$ using the random binary search. For example, $B(6) = 2.33333333$ and $R(6) = 2.71666667$ when rounded to $8$ decimal places.
Find $R(10^{10}) - B(10^{10})$ rounded to $8$ decimal places. | A secret integer $t$ is selected at random within the range $1 \le t \le n$.
The goal is to guess the value of $t$ by making repeated guesses, via integer $g$. After a guess is made, there are three possible outcomes, in which it will be revealed that either $g \lt t$, $g = t$, or $g \gt t$. Then the process can repeat as necessary.
Normally, the number of guesses required on average can be minimized with a binary search: Given a lower bound $L$ and upper bound $H$ (initialized to $L = 1$ and $H = n$), let $g = \lfloor(L+H)/2\rfloor$ where $\lfloor \cdot \rfloor$ is the integer floor function. If $g = t$, the process ends. Otherwise, if $g \lt t$, set $L = g+1$, but if $g \gt t$ instead, set $H = g - 1$. After setting the new bounds, the search process repeats, and ultimately ends once $t$ is found. Even if $t$ can be deduced without searching, assume that a search will be required anyway to confirm the value.
Your friend Bob believes that the standard binary search is not that much better than his randomized variant: Instead of setting $g = \lfloor(L+H)/2\rfloor$, simply let $g$ be a random integer between $L$ and $H$, inclusive. The rest of the algorithm is the same as the standard binary search. This new search routine will be referred to as a random binary search.
Given that $1 \le t \le n$ for random $t$, let $B(n)$ be the expected number of guesses needed to find $t$ using the standard binary search, and let $R(n)$ be the expected number of guesses needed to find $t$ using the random binary search. For example, $B(6) = 2.33333333$ and $R(6) = 2.71666667$ when rounded to $8$ decimal places.
Find $R(10^{10}) - B(10^{10})$ rounded to $8$ decimal places. | <p>A secret integer $t$ is selected at random within the range $1 \le t \le n$. </p>
<p>The goal is to guess the value of $t$ by making repeated guesses, via integer $g$. After a guess is made, there are three possible outcomes, in which it will be revealed that either $g \lt t$, $g = t$, or $g \gt t$. Then the process can repeat as necessary.</p>
<p>Normally, the number of guesses required on average can be minimized with a binary search: Given a lower bound $L$ and upper bound $H$ (initialized to $L = 1$ and $H = n$), let $g = \lfloor(L+H)/2\rfloor$ where $\lfloor \cdot \rfloor$ is the integer floor function. If $g = t$, the process ends. Otherwise, if $g \lt t$, set $L = g+1$, but if $g \gt t$ instead, set $H = g - 1$. After setting the new bounds, the search process repeats, and ultimately ends once $t$ is found. Even if $t$ can be deduced without searching, assume that a search will be required anyway to confirm the value.</p>
<p>Your friend Bob believes that the standard binary search is not that much better than his randomized variant: Instead of setting $g = \lfloor(L+H)/2\rfloor$, simply let $g$ be a random integer between $L$ and $H$, inclusive. The rest of the algorithm is the same as the standard binary search. This new search routine will be referred to as a <dfn>random binary search</dfn>.</p>
<p>Given that $1 \le t \le n$ for random $t$, let $B(n)$ be the expected number of guesses needed to find $t$ using the standard binary search, and let $R(n)$ be the expected number of guesses needed to find $t$ using the random binary search. For example, $B(6) = 2.33333333$ and $R(6) = 2.71666667$ when rounded to $8$ decimal places.</p>
<p>Find $R(10^{10}) - B(10^{10})$ rounded to $8$ decimal places.</p> | 11.92412011 | Saturday, 26th September 2015, 04:00 pm | 805 | 30% | easy |
142 | Perfect Square Collection | Find the smallest $x + y + z$ with integers $x \gt y \gt z \gt 0$ such that $x + y$, $x - y$, $x + z$, $x - z$, $y + z$, $y - z$ are all perfect squares. | Find the smallest $x + y + z$ with integers $x \gt y \gt z \gt 0$ such that $x + y$, $x - y$, $x + z$, $x - z$, $y + z$, $y - z$ are all perfect squares. | <p>Find the smallest $x + y + z$ with integers $x \gt y \gt z \gt 0$ such that $x + y$, $x - y$, $x + z$, $x - z$, $y + z$, $y - z$ are all perfect squares.</p> | 1006193 | Saturday, 24th February 2007, 01:00 am | 6495 | 45% | medium |
707 | Lights Out | Consider a $w\times h$ grid. A cell is either ON or OFF. When a cell is selected, that cell and all cells connected to that cell by an edge are toggled on-off, off-on. See the diagram for the 3 cases of selecting a corner cell, an edge cell or central cell in a grid that has all cells on (white).
The goal is to get every cell to be off simultaneously. This is not possible for all starting states. A state is solvable if, by a process of selecting cells, the goal can be achieved.
Let $F(w,h)$ be the number of solvable states for a $w\times h$ grid.
You are given $F(1,2)=2$, $F(3,3) = 512$, $F(4,4) = 4096$ and $F(7,11) \equiv 270016253 \pmod{1\,000\,000\,007}$.
Let $f_1=f_2 = 1$ and $f_n=f_{n-1}+f_{n-2}, n \ge 3$ be the Fibonacci sequence and define
$$ S(w,n) = \sum_{k=1}^n F(w,f_k)$$
You are given $S(3,3) = 32$, $S(4,5) = 1052960$ and $S(5,7) \equiv 346547294 \pmod{1\,000\,000\,007}$.
Find $S(199,199)$. Give your answer modulo $1\,000\,000\,007$. | Consider a $w\times h$ grid. A cell is either ON or OFF. When a cell is selected, that cell and all cells connected to that cell by an edge are toggled on-off, off-on. See the diagram for the 3 cases of selecting a corner cell, an edge cell or central cell in a grid that has all cells on (white).
The goal is to get every cell to be off simultaneously. This is not possible for all starting states. A state is solvable if, by a process of selecting cells, the goal can be achieved.
Let $F(w,h)$ be the number of solvable states for a $w\times h$ grid.
You are given $F(1,2)=2$, $F(3,3) = 512$, $F(4,4) = 4096$ and $F(7,11) \equiv 270016253 \pmod{1\,000\,000\,007}$.
Let $f_1=f_2 = 1$ and $f_n=f_{n-1}+f_{n-2}, n \ge 3$ be the Fibonacci sequence and define
$$ S(w,n) = \sum_{k=1}^n F(w,f_k)$$
You are given $S(3,3) = 32$, $S(4,5) = 1052960$ and $S(5,7) \equiv 346547294 \pmod{1\,000\,000\,007}$.
Find $S(199,199)$. Give your answer modulo $1\,000\,000\,007$. | <p>
Consider a $w\times h$ grid. A cell is either ON or OFF. When a cell is selected, that cell and all cells connected to that cell by an edge are toggled on-off, off-on. See the diagram for the 3 cases of selecting a corner cell, an edge cell or central cell in a grid that has all cells on (white).
</p>
<div class="center">
<img alt="LightsOut" src="project/images/p707_LightsOutPic.jpg"/></div>
<p>The goal is to get every cell to be off simultaneously. This is not possible for all starting states. A state is solvable if, by a process of selecting cells, the goal can be achieved.
</p>
<p>
Let $F(w,h)$ be the number of solvable states for a $w\times h$ grid.
You are given $F(1,2)=2$, $F(3,3) = 512$, $F(4,4) = 4096$ and $F(7,11) \equiv 270016253 \pmod{1\,000\,000\,007}$.
</p>
<p>
Let $f_1=f_2 = 1$ and $f_n=f_{n-1}+f_{n-2}, n \ge 3$ be the Fibonacci sequence and define
$$ S(w,n) = \sum_{k=1}^n F(w,f_k)$$
You are given $S(3,3) = 32$, $S(4,5) = 1052960$ and $S(5,7) \equiv 346547294 \pmod{1\,000\,000\,007}$.
</p>
<p>
Find $S(199,199)$. Give your answer modulo $1\,000\,000\,007$.
</p> | 652907799 | Sunday, 22nd March 2020, 10:00 am | 254 | 55% | medium |
549 | Divisibility of Factorials | The smallest number $m$ such that $10$ divides $m!$ is $m=5$.
The smallest number $m$ such that $25$ divides $m!$ is $m=10$.
Let $s(n)$ be the smallest number $m$ such that $n$ divides $m!$.
So $s(10)=5$ and $s(25)=10$.
Let $S(n)$ be $\sum s(i)$ for $2 \le i \le n$.
$S(100)=2012$.
Find $S(10^8)$. | The smallest number $m$ such that $10$ divides $m!$ is $m=5$.
The smallest number $m$ such that $25$ divides $m!$ is $m=10$.
Let $s(n)$ be the smallest number $m$ such that $n$ divides $m!$.
So $s(10)=5$ and $s(25)=10$.
Let $S(n)$ be $\sum s(i)$ for $2 \le i \le n$.
$S(100)=2012$.
Find $S(10^8)$. | <p>
The smallest number $m$ such that $10$ divides $m!$ is $m=5$.<br/>
The smallest number $m$ such that $25$ divides $m!$ is $m=10$.<br/>
</p>
<p>
Let $s(n)$ be the smallest number $m$ such that $n$ divides $m!$.<br/>
So $s(10)=5$ and $s(25)=10$.<br/>
Let $S(n)$ be $\sum s(i)$ for $2 \le i \le n$.<br/>
$S(100)=2012$.
</p>
<p>
Find $S(10^8)$.
</p> | 476001479068717 | Sunday, 28th February 2016, 10:00 am | 3048 | 15% | easy |
610 | Roman Numerals II | A random generator produces a sequence of symbols drawn from the set {I, V, X, L, C, D, M, #}. Each item in the sequence is determined by selecting one of these symbols at random, independently of the other items in the sequence. At each step, the seven letters are equally likely to be selected, with probability 14% each, but the # symbol only has a 2% chance of selection.
We write down the sequence of letters from left to right as they are generated, and we stop at the first occurrence of the # symbol (without writing it). However, we stipulate that what we have written down must always (when non-empty) be a valid Roman numeral representation in minimal form. If appending the next letter would contravene this then we simply skip it and try again with the next symbol generated.
Please take careful note of About... Roman Numerals for the definitive rules for this problem on what constitutes a "valid Roman numeral representation" and "minimal form". For example, the (only) sequence that represents 49 is XLIX. The subtractive combination IL is invalid because of rule (ii), while XXXXIX is valid but not minimal. The rules do not place any restriction on the number of occurrences of M, so all positive integers have a valid representation. These are the same rules as were used in Problem 89, and members are invited to solve that problem first.
Find the expected value of the number represented by what we have written down when we stop. (If nothing is written down then count that as zero.) Give your answer rounded to 8 places after the decimal point. | A random generator produces a sequence of symbols drawn from the set {I, V, X, L, C, D, M, #}. Each item in the sequence is determined by selecting one of these symbols at random, independently of the other items in the sequence. At each step, the seven letters are equally likely to be selected, with probability 14% each, but the # symbol only has a 2% chance of selection.
We write down the sequence of letters from left to right as they are generated, and we stop at the first occurrence of the # symbol (without writing it). However, we stipulate that what we have written down must always (when non-empty) be a valid Roman numeral representation in minimal form. If appending the next letter would contravene this then we simply skip it and try again with the next symbol generated.
Please take careful note of About... Roman Numerals for the definitive rules for this problem on what constitutes a "valid Roman numeral representation" and "minimal form". For example, the (only) sequence that represents 49 is XLIX. The subtractive combination IL is invalid because of rule (ii), while XXXXIX is valid but not minimal. The rules do not place any restriction on the number of occurrences of M, so all positive integers have a valid representation. These are the same rules as were used in Problem 89, and members are invited to solve that problem first.
Find the expected value of the number represented by what we have written down when we stop. (If nothing is written down then count that as zero.) Give your answer rounded to 8 places after the decimal point. | <p>A random generator produces a sequence of symbols drawn from the set {<span style="font-family:'courier new', monospace;">I</span>, <span style="font-family:'courier new', monospace;">V</span>, <span style="font-family:'courier new', monospace;">X</span>, <span style="font-family:'courier new', monospace;">L</span>, <span style="font-family:'courier new', monospace;">C</span>, <span style="font-family:'courier new', monospace;">D</span>, <span style="font-family:'courier new', monospace;">M</span>, <span style="font-family:'courier new', monospace;">#</span>}. Each item in the sequence is determined by selecting one of these symbols at random, independently of the other items in the sequence. At each step, the seven letters are equally likely to be selected, with probability 14% each, but the <span style="font-family:'courier new', monospace;">#</span> symbol only has a 2% chance of selection.</p>
<p>We write down the sequence of letters from left to right as they are generated, and we stop at the first occurrence of the <span style="font-family:'courier new', monospace;">#</span> symbol (without writing it). However, we stipulate that what we have written down must always (when non-empty) be a valid Roman numeral representation in minimal form. If appending the next letter would contravene this then we simply skip it and try again with the next symbol generated.</p>
<p>Please take careful note of <a href="about=roman_numerals">About... Roman Numerals</a> for the definitive rules for this problem on what constitutes a "valid Roman numeral representation" and "minimal form". For example, the (only) sequence that represents 49 is <span style="font-family:'courier new', monospace;">XLIX</span>. The subtractive combination <span style="font-family:'courier new', monospace;">IL</span> is invalid because of rule (ii), while <span style="font-family:'courier new', monospace;">XXXXIX</span> is valid but not minimal. The rules do not place any restriction on the number of occurrences of <span style="font-family:'courier new', monospace;">M</span>, so all positive integers have a valid representation. These are the same rules as were used in <a href="problem=89">Problem 89</a>, and members are invited to solve that problem first.</p>
<p>Find the expected value of the number represented by what we have written down when we stop. (If nothing is written down then count that as zero.) Give your answer rounded to 8 places after the decimal point.</p> | 319.30207833 | Saturday, 23rd September 2017, 07:00 pm | 657 | 35% | medium |
649 | Low-Prime Chessboard Nim | Alice and Bob are taking turns playing a game consisting of $c$ different coins on a chessboard of size $n$ by $n$.
The game may start with any arrangement of $c$ coins in squares on the board. It is possible at any time for more than one coin to occupy the same square on the board at the same time. The coins are distinguishable, so swapping two coins gives a different arrangement if (and only if) they are on different squares.
On a given turn, the player must choose a coin and move it either left or up $2$, $3$, $5$, or $7$ spaces in a single direction. The only restriction is that the coin cannot move off the edge of the board.
The game ends when a player is unable to make a valid move, thereby granting the other player the victory.
Assuming that Alice goes first and that both players are playing optimally, let $M(n, c)$ be the number of possible starting arrangements for which Alice can ensure her victory, given a board of size $n$ by $n$ with $c$ distinct coins.
For example, $M(3, 1) = 4$, $M(3, 2) = 40$, and $M(9, 3) = 450304$.
What are the last $9$ digits of $M(10\,000\,019, 100)$? | Alice and Bob are taking turns playing a game consisting of $c$ different coins on a chessboard of size $n$ by $n$.
The game may start with any arrangement of $c$ coins in squares on the board. It is possible at any time for more than one coin to occupy the same square on the board at the same time. The coins are distinguishable, so swapping two coins gives a different arrangement if (and only if) they are on different squares.
On a given turn, the player must choose a coin and move it either left or up $2$, $3$, $5$, or $7$ spaces in a single direction. The only restriction is that the coin cannot move off the edge of the board.
The game ends when a player is unable to make a valid move, thereby granting the other player the victory.
Assuming that Alice goes first and that both players are playing optimally, let $M(n, c)$ be the number of possible starting arrangements for which Alice can ensure her victory, given a board of size $n$ by $n$ with $c$ distinct coins.
For example, $M(3, 1) = 4$, $M(3, 2) = 40$, and $M(9, 3) = 450304$.
What are the last $9$ digits of $M(10\,000\,019, 100)$? | Alice and Bob are taking turns playing a game consisting of $c$ different coins on a chessboard of size $n$ by $n$.
<p>The game may start with any arrangement of $c$ coins in squares on the board. It is possible at any time for more than one coin to occupy the same square on the board at the same time. The coins are distinguishable, so swapping two coins gives a different arrangement if (and only if) they are on different squares.</p>
<p>On a given turn, the player must choose a coin and move it either left or up $2$, $3$, $5$, or $7$ spaces in a single direction. The only restriction is that the coin cannot move off the edge of the board.</p>
<p>The game ends when a player is unable to make a valid move, thereby granting the other player the victory.</p>
<p>Assuming that Alice goes first and that both players are playing optimally, let $M(n, c)$ be the number of possible starting arrangements for which Alice can ensure her victory, given a board of size $n$ by $n$ with $c$ distinct coins.</p>
<p>For example, $M(3, 1) = 4$, $M(3, 2) = 40$, and $M(9, 3) = 450304$.</p>
<p>What are the last $9$ digits of $M(10\,000\,019, 100)$?</p> | 924668016 | Saturday, 29th December 2018, 01:00 pm | 463 | 30% | easy |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.