id
int64
1
981
problem
stringlengths
97
5.29k
raw_html
stringlengths
121
5.63k
url
stringlengths
34
36
answer
stringlengths
1
29
801
The positive integral solutions of the equation $x^y=y^x$ are $(2,4)$, $(4,2)$ and $(k,k)$ for all $k > 0$. For a given positive integer $n$, let $f(n)$ be the number of integral values $0 < x,y \leq n^2-n$ such that $$x^y\equiv y^x \pmod n.$$ For example, $f(5)=104$ and $f(97)=1614336$. Let $S(M,N)=\sum f(p)$ where the sum is taken over all primes $p$ satisfying $M\le p\le N$. You are given $S(1,10^2)=7381000$ and $S(1,10^5) \equiv 701331986 \pmod{993353399}$. Find $S(10^{16}, 10^{16}+10^6)$. Give your answer modulo $993353399$.
<p>The positive integral solutions of the equation $x^y=y^x$ are $(2,4)$, $(4,2)$ and $(k,k)$ for all $k &gt; 0$.</p> <p>For a given positive integer $n$, let $f(n)$ be the number of integral values $0 &lt; x,y \leq n^2-n$ such that $$x^y\equiv y^x \pmod n.$$ For example, $f(5)=104$ and $f(97)=1614336$.</p> <p>Let $S(M,N)=\sum f(p)$ where the sum is taken over all primes $p$ satisfying $M\le p\le N$.</p> <p>You are given $S(1,10^2)=7381000$ and $S(1,10^5) \equiv 701331986 \pmod{993353399}$.</p> <p>Find $S(10^{16}, 10^{16}+10^6)$. Give your answer modulo $993353399$.</p>
https://projecteuler.net/problem=801
638129754
802
Let $\Bbb R^2$ be the set of pairs of real numbers $(x, y)$. Let $\pi = 3.14159\cdots\ $. Consider the function $f$ from $\Bbb R^2$ to $\Bbb R^2$ defined by $f(x, y) = (x^2 - x - y^2, 2xy - y + \pi)$, and its $n$-th iterated composition $f^{(n)}(x, y) = f(f(\cdots f(x, y)\cdots))$. For example $f^{(3)}(x, y) = f(f(f(x, y)))$. A pair $(x, y)$ is said to have period $n$ if $n$ is the smallest positive integer such that $f^{(n)}(x, y) = (x, y)$. Let $P(n)$ denote the sum of $x$-coordinates of all points having period not exceeding $n$. Interestingly, $P(n)$ is always an integer. For example, $P(1) = 2$, $P(2) = 2$, $P(3) = 4$. Find $P(10^7)$ and give your answer modulo $1\,020\,340\,567$.
<p>Let $\Bbb R^2$ be the set of pairs of real numbers $(x, y)$. Let $\pi = 3.14159\cdots\ $.</p> <p>Consider the function $f$ from $\Bbb R^2$ to $\Bbb R^2$ defined by $f(x, y) = (x^2 - x - y^2, 2xy - y + \pi)$, and its $n$-th iterated composition $f^{(n)}(x, y) = f(f(\cdots f(x, y)\cdots))$. For example $f^{(3)}(x, y) = f(f(f(x, y)))$. A pair $(x, y)$ is said to have period $n$ if $n$ is the smallest positive integer such that $f^{(n)}(x, y) = (x, y)$.</p> <p>Let $P(n)$ denote the sum of $x$-coordinates of all points having period not exceeding $n$. Interestingly, $P(n)$ is always an integer. For example, $P(1) = 2$, $P(2) = 2$, $P(3) = 4$.</p> <p>Find $P(10^7)$ and give your answer modulo $1\,020\,340\,567$.</p>
https://projecteuler.net/problem=802
973873727
803
Rand48 is a pseudorandom number generator used by some programming languages. It generates a sequence from any given integer $0 \le a_0 < 2^{48}$ using the rule $a_n = (25214903917 \cdot a_{n - 1} + 11) \bmod 2^{48}$. Let $b_n = \lfloor a_n / 2^{16} \rfloor \bmod 52$. The sequence $b_0, b_1, \dots$ is translated to an infinite string $c = c_0c_1\dots$ via the rule: $0 \rightarrow$ a, $1\rightarrow$ b, $\dots$, $25 \rightarrow$ z, $26 \rightarrow$ A, $27 \rightarrow$ B, $\dots$, $51 \rightarrow$ Z. For example, if we choose $a_0 = 123456$, then the string $c$ starts with: "bQYicNGCY$\dots$". Moreover, starting from index $100$, we encounter the substring "RxqLBfWzv" for the first time. Alternatively, if $c$ starts with "EULERcats$\dots$", then $a_0$ must be $78580612777175$. Now suppose that the string $c$ starts with "PuzzleOne$\dots$". Find the starting index of the first occurrence of the substring "LuckyText" in $c$.
<p> <b>Rand48</b> is a pseudorandom number generator used by some programming languages. It generates a sequence from any given integer $0 \le a_0 &lt; 2^{48}$ using the rule $a_n = (25214903917 \cdot a_{n - 1} + 11) \bmod 2^{48}$. </p> <p> Let $b_n = \lfloor a_n / 2^{16} \rfloor \bmod 52$. The sequence $b_0, b_1, \dots$ is translated to an infinite string $c = c_0c_1\dots$ via the rule:<br> $0 \rightarrow$ a, $1\rightarrow$ b, $\dots$, $25 \rightarrow$ z, $26 \rightarrow$ A, $27 \rightarrow$ B, $\dots$, $51 \rightarrow$ Z. </p> <p> For example, if we choose $a_0 = 123456$, then the string $c$ starts with: "bQYicNGCY$\dots$".<br> Moreover, starting from index $100$, we encounter the substring "RxqLBfWzv" for the first time. </p> <p> Alternatively, if $c$ starts with "EULERcats$\dots$", then $a_0$ must be $78580612777175$. </p> <p> Now suppose that the string $c$ starts with "PuzzleOne$\dots$".<br> Find the starting index of the first occurrence of the substring "LuckyText" in $c$. </p>
https://projecteuler.net/problem=803
9300900470636
804
Let $g(n)$ denote the number of ways a positive integer $n$ can be represented in the form: $$x^2+xy+41y^2$$ where $x$ and $y$ are integers. For example, $g(53)=4$ due to $(x,y) \in \{(-4,1),(-3,-1),(3,1),(4,-1)\}$. Define $\displaystyle T(N)=\sum_{n=1}^{N}g(n)$. You are given $T(10^3)=474$ and $T(10^6)=492128$. Find $T(10^{16})$.
<p>Let $g(n)$ denote the number of ways a positive integer $n$ can be represented in the form: $$x^2+xy+41y^2$$ where $x$ and $y$ are integers. For example, $g(53)=4$ due to $(x,y) \in \{(-4,1),(-3,-1),(3,1),(4,-1)\}$.</p> <p>Define $\displaystyle T(N)=\sum_{n=1}^{N}g(n)$. You are given $T(10^3)=474$ and $T(10^6)=492128$.</p> <p>Find $T(10^{16})$.</p>
https://projecteuler.net/problem=804
4921370551019052
805
For a positive integer $n$, let $s(n)$ be the integer obtained by shifting the leftmost digit of the decimal representation of $n$ to the rightmost position. For example, $s(142857)=428571$ and $s(10)=1$. For a positive rational number $r$, we define $N(r)$ as the smallest positive integer $n$ such that $s(n)=r\cdot n$. If no such integer exists, then $N(r)$ is defined as zero. For example, $N(3)=142857$, $N(\tfrac 1{10})=10$ and $N(2) = 0$. Let $T(M)$ be the sum of $N(u^3/v^3)$ where $(u,v)$ ranges over all ordered pairs of coprime positive integers not exceeding $M$. For example, $T(3)\equiv 262429173 \pmod {1\,000\,000\,007}$. Find $T(200)$. Give your answer modulo $1\,000\,000\,007$.
<p> For a positive integer $n$, let $s(n)$ be the integer obtained by shifting the leftmost digit of the decimal representation of $n$ to the rightmost position.<br> For example, $s(142857)=428571$ and $s(10)=1$.</p> <p> For a positive rational number $r$, we define $N(r)$ as the smallest positive integer $n$ such that $s(n)=r\cdot n$.<br> If no such integer exists, then $N(r)$ is defined as zero.<br> For example, $N(3)=142857$, $N(\tfrac 1{10})=10$ and $N(2) = 0$.</p> <p> Let $T(M)$ be the sum of $N(u^3/v^3)$ where $(u,v)$ ranges over all ordered pairs of coprime positive integers not exceeding $M$.<br> For example, $T(3)\equiv 262429173 \pmod {1\,000\,000\,007}$.</p> <p> Find $T(200)$. Give your answer modulo $1\,000\,000\,007$. </p>
https://projecteuler.net/problem=805
119719335
806
This problem combines the game of Nim with the Towers of Hanoi. For a brief introduction to the rules of these games, please refer to Problem 301 and Problem 497, respectively. The unique shortest solution to the Towers of Hanoi problem with $n$ disks and $3$ pegs requires $2^n-1$ moves. Number the positions in the solution from index 0 (starting position, all disks on the first peg) to index $2^n-1$ (final position, all disks on the third peg). Each of these $2^n$ positions can be considered as the starting configuration for a game of Nim, in which two players take turns to select a peg and remove any positive number of disks from it. The winner is the player who removes the last disk. We define $f(n)$ to be the sum of the indices of those positions for which, when considered as a Nim game, the first player will lose (assuming an optimal strategy from both players). For $n=4$, the indices of losing positions in the shortest solution are 3,6,9 and 12. So we have $f(4) = 30$. You are given that $f(10) = 67518$. Find $f(10^5)$. Give your answer modulo $1\,000\,000\,007$.
<p>This problem combines the game of Nim with the Towers of Hanoi. For a brief introduction to the rules of these games, please refer to <a href="problem=301">Problem 301</a> and <a href="problem=497">Problem 497</a>, respectively.</p> <p>The unique shortest solution to the Towers of Hanoi problem with $n$ disks and $3$ pegs requires $2^n-1$ moves. Number the positions in the solution from index 0 (starting position, all disks on the first peg) to index $2^n-1$ (final position, all disks on the third peg).</p> <p>Each of these $2^n$ positions can be considered as the starting configuration for a game of Nim, in which two players take turns to select a peg and remove any positive number of disks from it. The winner is the player who removes the last disk.</p> <p>We define $f(n)$ to be the sum of the indices of those positions for which, when considered as a Nim game, the first player will lose (assuming an optimal strategy from both players).</p> <p>For $n=4$, the indices of losing positions in the shortest solution are 3,6,9 and 12. So we have $f(4) = 30$.</p> <p>You are given that $f(10) = 67518$.</p> <p>Find $f(10^5)$. Give your answer modulo $1\,000\,000\,007$.</p>
https://projecteuler.net/problem=806
94394343
807
Given a circle $C$ and an integer $n > 1$, we perform the following operations. In step $0$, we choose two uniformly random points $R_0$ and $B_0$ on $C$. In step $i$ ($1 \leq i < n$), we first choose a uniformly random point $R_i$ on $C$ and connect the points $R_{i - 1}$ and $R_i$ with a red rope; then choose a uniformly random point $B_i$ on $C$ and connect the points $B_{i - 1}$ and $B_i$ with a blue rope. In step $n$, we first connect the points $R_{n - 1}$ and $R_0$ with a red rope; then connect the points $B_{n - 1}$ and $B_0$ with a blue rope. Each rope is straight between its two end points, and lies above all previous ropes. After step $n$, we get a loop of red ropes, and a loop of blue ropes. Sometimes the two loops can be separated, as in the left figure below; sometimes they are "linked", hence cannot be separated, as in the middle and right figures below. Let $P(n)$ be the probability that the two loops can be separated. For example, $P(3) = \frac{11}{20}$ and $P(5) \approx 0.4304177690$. Find $P(80)$, rounded to $10$ digits after decimal point.
<p>Given a circle $C$ and an integer $n &gt; 1$, we perform the following operations.</p> <p>In step $0$, we choose two uniformly random points $R_0$ and $B_0$ on $C$.<br> In step $i$ ($1 \leq i &lt; n$), we first choose a uniformly random point $R_i$ on $C$ and connect the points $R_{i - 1}$ and $R_i$ with a red rope; then choose a uniformly random point $B_i$ on $C$ and connect the points $B_{i - 1}$ and $B_i$ with a blue rope.<br> In step $n$, we first connect the points $R_{n - 1}$ and $R_0$ with a red rope; then connect the points $B_{n - 1}$ and $B_0$ with a blue rope.<br> Each rope is straight between its two end points, and lies above all previous ropes.</p> <p>After step $n$, we get a loop of red ropes, and a loop of blue ropes.<br> Sometimes the two loops can be separated, as in the left figure below; sometimes they are "linked", hence cannot be separated, as in the middle and right figures below.</p> <div style="text-align:center;"> <img src="resources/images/0807.jpg?1678992055" class="dark_img" alt=""> </div> <p>Let $P(n)$ be the probability that the two loops can be separated.<br> For example, $P(3) = \frac{11}{20}$ and $P(5) \approx 0.4304177690$.</p> <p>Find $P(80)$, rounded to $10$ digits after decimal point.</p>
https://projecteuler.net/problem=807
0.1091523673
808
Both $169$ and $961$ are the square of a prime. $169$ is the reverse of $961$. We call a number a reversible prime square if: - It is not a palindrome, and - It is the square of a prime, and - Its reverse is also the square of a prime. $169$ and $961$ are not palindromes, so both are reversible prime squares. Find the sum of the first $50$ reversible prime squares.
<p> Both $169$ and $961$ are the square of a prime. $169$ is the reverse of $961$. </p> <p> We call a number a <dfn>reversible prime square</dfn> if:</p> <ol> <li>It is not a palindrome, and</li> <li>It is the square of a prime, and</li> <li>Its reverse is also the square of a prime.</li> </ol> <p> $169$ and $961$ are not palindromes, so both are reversible prime squares. </p> <p> Find the sum of the first $50$ reversible prime squares. </p>
https://projecteuler.net/problem=808
3807504276997394
809
The following is a function defined for all positive rational values of $x$. $$ f(x)=\begin{cases} x &x\text{ is integral}\\ f(\frac 1{1-x}) &x \lt 1\\ f\Big(\frac 1{\lceil x\rceil -x}-1+f(x-1)\Big) &\text{otherwise}\end{cases} $$ For example, $f(3/2)=3$, $f(1/6) = 65533$ and $f(13/10) = 7625597484985$. Find $f(22/7)$. Give your answer modulo $10^{15}$.
<p> The following is a function defined for all positive rational values of $x$. </p> $$ f(x)=\begin{cases} x &amp;x\text{ is integral}\\ f(\frac 1{1-x}) &amp;x \lt 1\\ f\Big(\frac 1{\lceil x\rceil -x}-1+f(x-1)\Big) &amp;\text{otherwise}\end{cases} $$ <p> For example, $f(3/2)=3$, $f(1/6) = 65533$ and $f(13/10) = 7625597484985$. </p> <p> Find $f(22/7)$. Give your answer modulo $10^{15}$. </p>
https://projecteuler.net/problem=809
75353432948733
810
We use $x\oplus y$ for the bitwise XOR of $x$ and $y$. Define the XOR-product of $x$ and $y$, denoted by $x \otimes y$, similar to a long multiplication in base $2$, except that the intermediate results are XORed instead of the usual integer addition. For example, $7 \otimes 3 = 9$, or in base $2$, $111_2 \otimes 11_2 = 1001_2$: $$ \begin{align*} \phantom{\otimes 111} 111_2 \\ \otimes \phantom{1111} 11_2 \\ \hline \phantom{\otimes 111} 111_2 \\ \oplus \phantom{11} 111_2 \phantom{9} \\ \hline \phantom{\otimes 11} 1001_2 \\ \end{align*} $$ An XOR-prime is an integer $n$ greater than $1$ that is not an XOR-product of two integers greater than $1$. The above example shows that $9$ is not an XOR-prime. Similarly, $5 = 3 \otimes 3$ is not an XOR-prime. The first few XOR-primes are $2, 3, 7, 11, 13, ...$ and the 10th XOR-prime is $41$. Find the $5\,000\,000$th XOR-prime.
<p>We use $x\oplus y$ for the bitwise XOR of $x$ and $y$.</p> <p>Define the <dfn>XOR-product</dfn> of $x$ and $y$, denoted by $x \otimes y$, similar to a long multiplication in base $2$, except that the intermediate results are XORed instead of the usual integer addition.</p> <p>For example, $7 \otimes 3 = 9$, or in base $2$, $111_2 \otimes 11_2 = 1001_2$:</p> $$ \begin{align*} \phantom{\otimes 111} 111_2 \\ \otimes \phantom{1111} 11_2 \\ \hline \phantom{\otimes 111} 111_2 \\ \oplus \phantom{11} 111_2 \phantom{9} \\ \hline \phantom{\otimes 11} 1001_2 \\ \end{align*} $$ <p>An <dfn>XOR-prime</dfn> is an integer $n$ greater than $1$ that is not an XOR-product of two integers greater than $1$. The above example shows that $9$ is not an XOR-prime. Similarly, $5 = 3 \otimes 3$ is not an XOR-prime. The first few XOR-primes are $2, 3, 7, 11, 13, ...$ and the 10th XOR-prime is $41$.</p> <p>Find the $5\,000\,000$th XOR-prime.</p>
https://projecteuler.net/problem=810
124136381
811
Let $b(n)$ be the largest power of 2 that divides $n$. For example $b(24) = 8$. Define the recursive function: $$\begin{align*} \begin{split} A(0) &= 1\\ A(2n) &= 3A(n) + 5A\big(2n - b(n)\big) \qquad n \gt 0\\ A(2n+1) &= A(n) \end{split} \end{align*}$$ and let $H(t,r) = A\big((2^t+1)^r\big)$. You are given $H(3,2) = A(81) = 636056$. Find $H(10^{14}+31,62)$. Give your answer modulo $1\,000\,062\,031$.
<p> Let $b(n)$ be the largest power of 2 that divides $n$. For example $b(24) = 8$.</p> <p> Define the recursive function: $$\begin{align*} \begin{split} A(0) &amp;= 1\\ A(2n) &amp;= 3A(n) + 5A\big(2n - b(n)\big) \qquad n \gt 0\\ A(2n+1) &amp;= A(n) \end{split} \end{align*}$$ and let $H(t,r) = A\big((2^t+1)^r\big)$.</p> <p> You are given $H(3,2) = A(81) = 636056$.</p> <p> Find $H(10^{14}+31,62)$. Give your answer modulo $1\,000\,062\,031$. </p>
https://projecteuler.net/problem=811
327287526
812
A dynamical polynomial is a monicleading coefficient is $1$ polynomial $f(x)$ with integer coefficients such that $f(x)$ divides $f(x^2-2)$. For example, $f(x) = x^2 - x - 2$ is a dynamical polynomial because $f(x^2-2) = x^4-5x^2+4 = (x^2 + x -2)f(x)$. Let $S(n)$ be the number of dynamical polynomials of degree $n$. For example, $S(2)=6$, as there are six dynamical polynomials of degree $2$: $$ x^2-4x+4 \quad,\quad x^2-x-2 \quad,\quad x^2-4 \quad,\quad x^2-1 \quad,\quad x^2+x-1 \quad,\quad x^2+2x+1 $$ Also, $S(5)=58$ and $S(20)=122087$. Find $S(10\,000)$. Give your answer modulo $998244353$.
<p>A <dfn>dynamical polynomial</dfn> is a <strong class="tooltip">monic<span class="tooltiptext">leading coefficient is $1$</span></strong> polynomial $f(x)$ with integer coefficients such that $f(x)$ divides $f(x^2-2)$.</p> <p>For example, $f(x) = x^2 - x - 2$ is a dynamical polynomial because $f(x^2-2) = x^4-5x^2+4 = (x^2 + x -2)f(x)$.</p> <p>Let $S(n)$ be the number of dynamical polynomials of degree $n$.<br> For example, $S(2)=6$, as there are six dynamical polynomials of degree $2$:</p> $$ x^2-4x+4 \quad,\quad x^2-x-2 \quad,\quad x^2-4 \quad,\quad x^2-1 \quad,\quad x^2+x-1 \quad,\quad x^2+2x+1 $$ <p>Also, $S(5)=58$ and $S(20)=122087$.</p> <p>Find $S(10\,000)$. Give your answer modulo $998244353$.</p>
https://projecteuler.net/problem=812
986262698
813
We use $x\oplus y$ to be the bitwise XOR of $x$ and $y$. Define the XOR-product of $x$ and $y$, denoted by $x \otimes y$, similar to a long multiplication in base $2$, except that the intermediate results are XORed instead of the usual integer addition. For example, $11 \otimes 11 = 69$, or in base $2$, $1011_2 \otimes 1011_2 = 1000101_2$: $$ \begin{align*} \phantom{\otimes 1111} 1011_2 \\ \otimes \phantom{1111} 1011_2 \\ \hline \phantom{\otimes 1111} 1011_2 \\ \phantom{\otimes 111} 1011_2 \phantom{9} \\ \oplus \phantom{1} 1011_2 \phantom{999} \\ \hline \phantom{\otimes 11} 1000101_2 \\ \end{align*} $$ Further we define $P(n) = 11^{\otimes n} = \overbrace{11\otimes 11\otimes \ldots \otimes 11}^n$. For example $P(2)=69$. Find $P(8^{12}\cdot 12^8)$. Give your answer modulo $10^9+7$.
<p>We use $x\oplus y$ to be the bitwise XOR of $x$ and $y$.</p> <p>Define the <dfn>XOR-product</dfn> of $x$ and $y$, denoted by $x \otimes y$, similar to a long multiplication in base $2$, except that the intermediate results are XORed instead of the usual integer addition.</p> <p>For example, $11 \otimes 11 = 69$, or in base $2$, $1011_2 \otimes 1011_2 = 1000101_2$:</p> $$ \begin{align*} \phantom{\otimes 1111} 1011_2 \\ \otimes \phantom{1111} 1011_2 \\ \hline \phantom{\otimes 1111} 1011_2 \\ \phantom{\otimes 111} 1011_2 \phantom{9} \\ \oplus \phantom{1} 1011_2 \phantom{999} \\ \hline \phantom{\otimes 11} 1000101_2 \\ \end{align*} $$ Further we define $P(n) = 11^{\otimes n} = \overbrace{11\otimes 11\otimes \ldots \otimes 11}^n$. For example $P(2)=69$. <p>Find $P(8^{12}\cdot 12^8)$. Give your answer modulo $10^9+7$.</p>
https://projecteuler.net/problem=813
14063639
814
$4n$ people stand in a circle with their heads down. When the bell rings they all raise their heads and either look at the person immediately to their left, the person immediately to their right or the person diametrically opposite. If two people find themselves looking at each other they both scream. Define $S(n)$ to be the number of ways that exactly half of the people scream. You are given $S(1) = 48$ and $S(10) \equiv 420121075 \mod{998244353}$. Find $S(10^3)$. Enter your answer modulo $998244353$.
<p> $4n$ people stand in a circle with their heads down. When the bell rings they all raise their heads and either look at the person immediately to their left, the person immediately to their right or the person diametrically opposite. If two people find themselves looking at each other they both scream.</p> <p> Define $S(n)$ to be the number of ways that exactly half of the people scream. You are given $S(1) = 48$ and $S(10) \equiv 420121075 \mod{998244353}$.</p> <p> Find $S(10^3)$. Enter your answer modulo $998244353$.</p>
https://projecteuler.net/problem=814
307159326
815
A pack of cards contains $4n$ cards with four identical cards of each value. The pack is shuffled and cards are dealt one at a time and placed in piles of equal value. If the card has the same value as any pile it is placed in that pile. If there is no pile of that value then it begins a new pile. When a pile has four cards of the same value it is removed. Throughout the process the maximum number of non empty piles is recorded. Let $E(n)$ be its expected value. You are given $E(2) = 1.97142857$ rounded to 8 decimal places. Find $E(60)$. Give your answer rounded to 8 digits after the decimal point.
<p> A pack of cards contains $4n$ cards with four identical cards of each value. The pack is shuffled and cards are dealt one at a time and placed in piles of equal value. If the card has the same value as any pile it is placed in that pile. If there is no pile of that value then it begins a new pile. When a pile has four cards of the same value it is removed.</p> <p> Throughout the process the maximum number of non empty piles is recorded. Let $E(n)$ be its expected value. You are given $E(2) = 1.97142857$ rounded to 8 decimal places.</p> <p> Find $E(60)$. Give your answer rounded to 8 digits after the decimal point. </p>
https://projecteuler.net/problem=815
54.12691621
816
We create an array of points $P_n$ in a two dimensional plane using the following random number generator: $s_0=290797$ $s_{n+1}={s_n}^2 \bmod 50515093$ $P_n=(s_{2n},s_{2n+1})$ Let $d(k)$ be the shortest distance of any two (distinct) points among $P_0, \cdots, P_{k - 1}$. E.g. $d(14)=546446.466846479$. Find $d(2000000)$. Give your answer rounded to $9$ places after the decimal point.
<p>We create an array of points $P_n$ in a two dimensional plane using the following random number generator:<br> $s_0=290797$<br> $s_{n+1}={s_n}^2 \bmod 50515093$ <br> <br> $P_n=(s_{2n},s_{2n+1})$</p> <p> Let $d(k)$ be the shortest distance of any two (distinct) points among $P_0, \cdots, P_{k - 1}$.<br> E.g. $d(14)=546446.466846479$. </p> <p> Find $d(2000000)$. Give your answer rounded to $9$ places after the decimal point. </p>
https://projecteuler.net/problem=816
20.880613018
817
Define $m = M(n, d)$ to be the smallest positive integer such that when $m^2$ is written in base $n$ it includes the base $n$ digit $d$. For example, $M(10,7) = 24$ because if all the squares are written out in base 10 the first time the digit 7 occurs is in $24^2 = 576$. $M(11,10) = 19$ as $19^2 = 361=2A9_{11}$. Find $\displaystyle \sum_{d = 1}^{10^5}M(p, p - d)$ where $p = 10^9 + 7$.
<p> Define $m = M(n, d)$ to be the smallest positive integer such that when $m^2$ is written in base $n$ it includes the base $n$ digit $d$. For example, $M(10,7) = 24$ because if all the squares are written out in base 10 the first time the digit 7 occurs is in $24^2 = 576$. $M(11,10) = 19$ as $19^2 = 361=2A9_{11}$.</p> <p> Find $\displaystyle \sum_{d = 1}^{10^5}M(p, p - d)$ where $p = 10^9 + 7$.</p>
https://projecteuler.net/problem=817
93158936107011
818
The SET® card game is played with a pack of $81$ distinct cards. Each card has four features (Shape, Color, Number, Shading). Each feature has three different variants (e.g. Color can be red, purple, green). A SET consists of three different cards such that each feature is either the same on each card or different on each card. For a collection $C_n$ of $n$ cards, let $S(C_n)$ denote the number of SETs in $C_n$. Then define $F(n) = \sum\limits_{C_n} S(C_n)^4$ where $C_n$ ranges through all collections of $n$ cards (among the $81$ cards). You are given $F(3) = 1080$ and $F(6) = 159690960$. Find $F(12)$. $\scriptsize{\text{SET is a registered trademark of Cannei, LLC. All rights reserved. Used with permission from PlayMonster, LLC.}}$
<p> The SET® card game is played with a pack of $81$ distinct cards. Each card has four features (Shape, Color, Number, Shading). Each feature has three different variants (e.g. Color can be red, purple, green).</p> <p> A <i>SET</i> consists of three different cards such that each feature is either the same on each card or different on each card.</p> <p> For a collection $C_n$ of $n$ cards, let $S(C_n)$ denote the number of <i>SET</i>s in $C_n$. Then define $F(n) = \sum\limits_{C_n} S(C_n)^4$ where $C_n$ ranges through all collections of $n$ cards (among the $81$ cards). You are given $F(3) = 1080$ and $F(6) = 159690960$.</p> <p> Find $F(12)$.</p> <p> $\scriptsize{\text{SET is a registered trademark of Cannei, LLC. All rights reserved. Used with permission from PlayMonster, LLC.}}$</p>
https://projecteuler.net/problem=818
11871909492066000
819
Given an $n$-tuple of numbers another $n$-tuple is created where each element of the new $n$-tuple is chosen randomly from the numbers in the previous $n$-tuple. For example, given $(2,2,3)$ the probability that $2$ occurs in the first position in the next 3-tuple is $2/3$. The probability of getting all $2$'s would be $8/27$ while the probability of getting the same 3-tuple (in any order) would be $4/9$. Let $E(n)$ be the expected number of steps starting with $(1,2,\ldots,n)$ and ending with all numbers being the same. You are given $E(3) = 27/7$ and $E(5) = 468125/60701 \approx 7.711982$ rounded to 6 digits after the decimal place. Find $E(10^3)$. Give the answer rounded to 6 digits after the decimal place.
<p>Given an $n$-tuple of numbers another $n$-tuple is created where each element of the new $n$-tuple is chosen randomly from the numbers in the previous $n$-tuple. For example, given $(2,2,3)$ the probability that $2$ occurs in the first position in the next 3-tuple is $2/3$. The probability of getting all $2$'s would be $8/27$ while the probability of getting the same 3-tuple (in any order) would be $4/9$.</p> <p>Let $E(n)$ be the expected number of steps starting with $(1,2,\ldots,n)$ and ending with all numbers being the same.</p> <p>You are given $E(3) = 27/7$ and $E(5) = 468125/60701 \approx 7.711982$ rounded to 6 digits after the decimal place.</p> <p>Find $E(10^3)$. Give the answer rounded to 6 digits after the decimal place.</p>
https://projecteuler.net/problem=819
1995.975556
820
Let $d_n(x)$ be the $n$th decimal digit of the fractional part of $x$, or $0$ if the fractional part has fewer than $n$ digits. For example: - $d_7 \mathopen{}\left( 1 \right)\mathclose{} = d_7 \mathopen{}\left( \frac 1 2 \right)\mathclose{} = d_7 \mathopen{}\left( \frac 1 4 \right)\mathclose{} = d_7 \mathopen{}\left( \frac 1 5 \right)\mathclose{} = 0$ - $d_7 \mathopen{}\left( \frac 1 3 \right)\mathclose{} = 3$ since $\frac 1 3 =$ 0.3333333333... - $d_7 \mathopen{}\left( \frac 1 6 \right)\mathclose{} = 6$ since $\frac 1 6 =$ 0.1666666666... - $d_7 \mathopen{}\left( \frac 1 7 \right)\mathclose{} = 1$ since $\frac 1 7 =$ 0.1428571428... Let $\displaystyle S(n) = \sum_{k=1}^n d_n \mathopen{}\left( \frac 1 k \right)\mathclose{}$. You are given: - $S(7) = 0 + 0 + 3 + 0 + 0 + 6 + 1 = 10$ - $S(100) = 418$ Find $S(10^7)$.
<p>Let $d_n(x)$ be the $n$<sup>th</sup> decimal digit of the fractional part of $x$, or $0$ if the fractional part has fewer than $n$ digits.</p> <p>For example:</p> <ul> <li>$d_7 \mathopen{}\left( 1 \right)\mathclose{} = d_7 \mathopen{}\left( \frac 1 2 \right)\mathclose{} = d_7 \mathopen{}\left( \frac 1 4 \right)\mathclose{} = d_7 \mathopen{}\left( \frac 1 5 \right)\mathclose{} = 0$</li> <li>$d_7 \mathopen{}\left( \frac 1 3 \right)\mathclose{} = 3$ since $\frac 1 3 =$ 0.333333<span style="color:#FF0000;font-weight:bold;">3</span>333...</li> <li>$d_7 \mathopen{}\left( \frac 1 6 \right)\mathclose{} = 6$ since $\frac 1 6 =$ 0.166666<span style="color:#FF0000;font-weight:bold;">6</span>666...</li> <li>$d_7 \mathopen{}\left( \frac 1 7 \right)\mathclose{} = 1$ since $\frac 1 7 =$ 0.142857<span style="color:#FF0000;font-weight:bold;">1</span>428...</li> </ul> <p>Let $\displaystyle S(n) = \sum_{k=1}^n d_n \mathopen{}\left( \frac 1 k \right)\mathclose{}$.</p> <p>You are given:</p> <ul> <li>$S(7) = 0 + 0 + 3 + 0 + 0 + 6 + 1 = 10$</li> <li>$S(100) = 418$</li> </ul> <p>Find $S(10^7)$.</p>
https://projecteuler.net/problem=820
44967734
821
A set, $S$, of integers is called 123-separable if $S$, $2S$ and $3S$ are disjoint. Here $2S$ and $3S$ are obtained by multiplying all the elements in $S$ by $2$ and $3$ respectively. Define $F(n)$ to be the maximum number of elements of $$(S\cup 2S \cup 3S)\cap \{1,2,3,\ldots,n\}$$ where $S$ ranges over all 123-separable sets. For example, $F(6) = 5$ can be achieved with either $S = \{1,4,5\}$ or $S = \{1,5,6\}$. You are also given $F(20) = 19$. Find $F(10^{16})$.
<p> A set, $S$, of integers is called <dfn>123-separable</dfn> if $S$, $2S$ and $3S$ are disjoint. Here $2S$ and $3S$ are obtained by multiplying all the elements in $S$ by $2$ and $3$ respectively.</p> <p> Define $F(n)$ to be the maximum number of elements of $$(S\cup 2S \cup 3S)\cap \{1,2,3,\ldots,n\}$$ where $S$ ranges over all 123-separable sets.</p> <p> For example, $F(6) = 5$ can be achieved with either $S = \{1,4,5\}$ or $S = \{1,5,6\}$.<br> You are also given $F(20) = 19$.</p> <p> Find $F(10^{16})$.</p>
https://projecteuler.net/problem=821
9219661511328178
822
A list initially contains the numbers $2, 3, \dots, n$. At each round, the smallest number in the list is replaced by its square. If there is more than one such number, then only one of them is replaced. For example, below are the first three rounds for $n = 5$: $$[2, 3, 4, 5] \xrightarrow{(1)} [4, 3, 4, 5] \xrightarrow{(2)} [4, 9, 4, 5] \xrightarrow{(3)} [16, 9, 4, 5].$$ Let $S(n, m)$ be the sum of all numbers in the list after $m$ rounds. For example, $S(5, 3) = 16 + 9 + 4 + 5 = 34$. Also $S(10, 100) \equiv 845339386 \pmod{1234567891}$. Find $S(10^4, 10^{16})$. Give your answer modulo $1234567891$.
<p> A list initially contains the numbers $2, 3, \dots, n$.<br> At each round, the smallest number in the list is replaced by its square. If there is more than one such number, then only one of them is replaced. </p> <p> For example, below are the first three rounds for $n = 5$: $$[2, 3, 4, 5] \xrightarrow{(1)} [4, 3, 4, 5] \xrightarrow{(2)} [4, 9, 4, 5] \xrightarrow{(3)} [16, 9, 4, 5].$$ </p> <p> Let $S(n, m)$ be the sum of all numbers in the list after $m$ rounds.<br><br> For example, $S(5, 3) = 16 + 9 + 4 + 5 = 34$. Also $S(10, 100) \equiv 845339386 \pmod{1234567891}$. </p> <p> Find $S(10^4, 10^{16})$. Give your answer modulo $1234567891$. </p>
https://projecteuler.net/problem=822
950591530
823
A list initially contains the numbers $2, 3, \dots, n$. At each round, every number in the list is divided by its smallest prime factor. Then the product of these smallest prime factors is added to the list as a new number. Finally, all numbers that become $1$ are removed from the list. For example, below are the first three rounds for $n = 5$: $$[2, 3, 4, 5] \xrightarrow{(1)} [2, 60] \xrightarrow{(2)} [30, 4] \xrightarrow{(3)} [15, 2, 4].$$ Let $S(n, m)$ be the sum of all numbers in the list after $m$ rounds. For example, $S(5, 3) = 15 + 2 + 4 = 21$. Also $S(10, 100) = 257$. Find $S(10^4, 10^{16})$. Give your answer modulo $1234567891$.
<p>A list initially contains the numbers $2, 3, \dots, n$.<br> At each round, every number in the list is divided by its smallest prime factor. Then the product of these smallest prime factors is added to the list as a new number. Finally, all numbers that become $1$ are removed from the list.</p> <p>For example, below are the first three rounds for $n = 5$: $$[2, 3, 4, 5] \xrightarrow{(1)} [2, 60] \xrightarrow{(2)} [30, 4] \xrightarrow{(3)} [15, 2, 4].$$ Let $S(n, m)$ be the sum of all numbers in the list after $m$ rounds.<br> For example, $S(5, 3) = 15 + 2 + 4 = 21$. Also $S(10, 100) = 257$.</p> <p>Find $S(10^4, 10^{16})$. Give your answer modulo $1234567891$.</p>
https://projecteuler.net/problem=823
865849519
824
A Slider is a chess piece that can move one square left or right. This problem uses a cylindrical chess board where the left hand edge of the board is connected to the right hand edge. This means that a Slider that is on the left hand edge of the chess board can move to the right hand edge of the same row and vice versa. Let $L(N,K)$ be the number of ways $K$ non-attacking Sliders can be placed on an $N \times N$ cylindrical chess-board. For example, $L(2,2)=4$ and $L(6,12)=4204761$. Find $L(10^9,10^{15}) \bmod \left(10^7+19\right)^2$.
<p>A <dfn>Slider</dfn> is a chess piece that can move one square left or right.</p> <p>This problem uses a cylindrical chess board where the left hand edge of the board is connected to the right hand edge. This means that a Slider that is on the left hand edge of the chess board can move to the right hand edge of the same row and vice versa.</p> <p>Let $L(N,K)$ be the number of ways $K$ non-attacking Sliders can be placed on an $N \times N$ cylindrical chess-board.</p> <p>For example, $L(2,2)=4$ and $L(6,12)=4204761$.</p> <p>Find $L(10^9,10^{15}) \bmod \left(10^7+19\right)^2$.</p>
https://projecteuler.net/problem=824
26532152736197
825
Two cars are on a circular track of total length $2n$, facing the same direction, initially distance $n$ apart. They move in turn. At each turn, the moving car will advance a distance of $1$, $2$ or $3$, with equal probabilities. The chase ends when the moving car reaches or goes beyond the position of the other car. The moving car is declared the winner. Let $S(n)$ be the difference between the winning probabilities of the two cars. For example, when $n = 2$, the winning probabilities of the two cars are $\frac 9 {11}$ and $\frac 2 {11}$, and thus $S(2) = \frac 7 {11}$. Let $\displaystyle T(N) = \sum_{n = 2}^N S(n)$. You are given that $T(10) = 2.38235282$ rounded to 8 digits after the decimal point. Find $T(10^{14})$, rounded to 8 digits after the decimal point.
<p>Two cars are on a circular track of total length $2n$, facing the same direction, initially distance $n$ apart.<br> They move in turn. At each turn, the moving car will advance a distance of $1$, $2$ or $3$, with equal probabilities.<br> The chase ends when the moving car reaches or goes beyond the position of the other car. The moving car is declared the winner.</p> <p>Let $S(n)$ be the difference between the winning probabilities of the two cars.<br> For example, when $n = 2$, the winning probabilities of the two cars are $\frac 9 {11}$ and $\frac 2 {11}$, and thus $S(2) = \frac 7 {11}$.</p> <p>Let $\displaystyle T(N) = \sum_{n = 2}^N S(n)$.</p> <p>You are given that $T(10) = 2.38235282$ rounded to 8 digits after the decimal point.</p> <p>Find $T(10^{14})$, rounded to 8 digits after the decimal point.</p>
https://projecteuler.net/problem=825
32.34481054
826
Consider a wire of length 1 unit between two posts. Every morning $n$ birds land on it randomly with every point on the wire equally likely to host a bird. The interval from each bird to its closest neighbour is then painted. Define $F(n)$ to be the expected length of the wire that is painted. You are given $F(3) = 0.5$. Find the average of $F(n)$ where $n$ ranges through all odd prime less than a million. Give your answer rounded to 10 places after the decimal point.
<p>Consider a wire of length 1 unit between two posts. Every morning $n$ birds land on it randomly with every point on the wire equally likely to host a bird. The interval from each bird to its closest neighbour is then painted.</p> <p>Define $F(n)$ to be the expected length of the wire that is painted. You are given $F(3) = 0.5$.</p> <p>Find the average of $F(n)$ where $n$ ranges through all odd prime less than a million. Give your answer rounded to 10 places after the decimal point.</p>
https://projecteuler.net/problem=826
0.3889014797
827
Define $Q(n)$ to be the smallest number that occurs in exactly $n$ Pythagorean triples $(a,b,c)$ where $a \lt b \lt c$. For example, $15$ is the smallest number occurring in exactly $5$ Pythagorean triples: $$(9,12,\mathbf{15})\quad (8,\mathbf{15},17)\quad (\mathbf{15},20,25)\quad (\mathbf{15},36,39)\quad (\mathbf{15},112,113)$$ and so $Q(5) = 15$. You are also given $Q(10)=48$ and $Q(10^3)=8064000$. Find $\displaystyle \sum_{k=1}^{18} Q(10^k)$. Give your answer modulo $409120391$.
<p> Define $Q(n)$ to be the smallest number that occurs in exactly $n$ <strong>Pythagorean triples</strong> $(a,b,c)$ where $a \lt b \lt c$.</p> <p> For example, $15$ is the smallest number occurring in exactly $5$ Pythagorean triples: $$(9,12,\mathbf{15})\quad (8,\mathbf{15},17)\quad (\mathbf{15},20,25)\quad (\mathbf{15},36,39)\quad (\mathbf{15},112,113)$$ and so $Q(5) = 15$.</p> <p> You are also given $Q(10)=48$ and $Q(10^3)=8064000$.</p> <p> Find $\displaystyle \sum_{k=1}^{18} Q(10^k)$. Give your answer modulo $409120391$.</p>
https://projecteuler.net/problem=827
397289979
828
It is a common recreational problem to make a target number using a selection of other numbers. In this problem you will be given six numbers and a target number. For example, given the six numbers $2$, $3$, $4$, $6$, $7$, $25$, and a target of $211$, one possible solution is: $$211 = (3+6)\times 25 − (4\times7)\div 2$$ This uses all six numbers. However, it is not necessary to do so. Another solution that does not use the $7$ is: $$211 = (25−2)\times (6+3) + 4$$ Define the score of a solution to be the sum of the numbers used. In the above example problem, the two given solutions have scores $47$ and $40$ respectively. It turns out that this problem has no solutions with score less than $40$. When combining numbers, the following rules must be observed: - Each available number may be used at most once. - Only the four basic arithmetic operations are permitted: $+$, $-$, $\times$, $\div$. - All intermediate values must be positive integers, so for example $(3\div 2)$ is never permitted as a subexpression (even if the final answer is an integer). The attached file number-challenges.txt contains 200 problems, one per line in the format: 211:2,3,4,6,7,25 where the number before the colon is the target and the remaining comma-separated numbers are those available to be used. Numbering the problems 1, 2, ..., 200, we let $s_n$ be the minimum score of the solution to the $n$th problem. For example, $s_1=40$, as the first problem in the file is the example given above. Note that not all problems have a solution; in such cases we take $s_n=0$. Find $\displaystyle\sum_{n=1}^{200} 3^n s_n$. Give your answer modulo $1005075251$.
<p>It is a common recreational problem to make a target number using a selection of other numbers. In this problem you will be given six numbers and a target number.</p> <p>For example, given the six numbers $2$, $3$, $4$, $6$, $7$, $25$, and a target of $211$, one possible solution is:</p> $$211 = (3+6)\times 25 − (4\times7)\div 2$$ <p>This uses all six numbers. However, it is not necessary to do so. Another solution that does not use the $7$ is:</p> $$211 = (25−2)\times (6+3) + 4$$ <p>Define the <em>score</em> of a solution to be the sum of the numbers used. In the above example problem, the two given solutions have scores $47$ and $40$ respectively. It turns out that this problem has no solutions with score less than $40$.</p> <p>When combining numbers, the following rules must be observed:</p> <ul> <li>Each available number may be used at most once.</li> <li>Only the four basic arithmetic operations are permitted: $+$, $-$, $\times$, $\div$.</li> <li>All intermediate values must be positive integers, so for example $(3\div 2)$ is never permitted as a subexpression (even if the final answer is an integer).</li> </ul> <p>The attached file <a href="resources/documents/0828_number_challenges.txt">number-challenges.txt</a> contains 200 problems, one per line in the format:</p> <center><big><tt>211:2,3,4,6,7,25</tt></big></center> <p>where the number before the colon is the target and the remaining comma-separated numbers are those available to be used.</p> <p>Numbering the problems 1, 2, ..., 200, we let $s_n$ be the minimum score of the solution to the $n$th problem. For example, $s_1=40$, as the first problem in the file is the example given above. Note that not all problems have a solution; in such cases we take $s_n=0$.</p> <p>Find $\displaystyle\sum_{n=1}^{200} 3^n s_n$. Give your answer modulo $1005075251$.</p>
https://projecteuler.net/problem=828
148693670
829
Given any integer $n \gt 1$ a binary factor tree $T(n)$ is defined to be: - A tree with the single node $n$ when $n$ is prime. - A binary tree that has root node $n$, left subtree $T(a)$ and right subtree $T(b)$, when $n$ is not prime. Here $a$ and $b$ are positive integers such that $n = ab$, $a\le b$ and $b-a$ is the smallest. For example $T(20)$: We define $M(n)$ to be the smallest number that has a factor tree identical in shape to the factor tree for $n!!$, the double factorial of $n$. For example, consider $9!! = 9\times 7\times 5\times 3\times 1 = 945$. The factor tree for $945$ is shown below together with the factor tree for $72$ which is the smallest number that has a factor tree of the same shape. Hence $M(9) = 72$. Find $\displaystyle\sum_{n=2}^{31} M(n)$.
<p>Given any integer $n \gt 1$ a <dfn>binary factor tree</dfn> $T(n)$ is defined to be:</p> <ul> <li>A tree with the single node $n$ when $n$ is prime.</li> <li>A binary tree that has root node $n$, left subtree $T(a)$ and right subtree $T(b)$, when $n$ is not prime. Here $a$ and $b$ are positive integers such that $n = ab$, $a\le b$ and $b-a$ is the smallest.</li> </ul> <p>For example $T(20)$:</p> <img src="resources/images/0829_example1.jpg?1678992055" alt="0829_example1.jpg"> <p>We define $M(n)$ to be the smallest number that has a factor tree identical in shape to the factor tree for $n!!$, the <b>double factorial</b> of $n$.</p> <p>For example, consider $9!! = 9\times 7\times 5\times 3\times 1 = 945$. The factor tree for $945$ is shown below together with the factor tree for $72$ which is the smallest number that has a factor tree of the same shape. Hence $M(9) = 72$.</p> <img src="resources/images/0829_example2.jpg?1678992055" alt="0829_example2.jpg"> <p>Find $\displaystyle\sum_{n=2}^{31} M(n)$.</p>
https://projecteuler.net/problem=829
41768797657018024
830
Let $\displaystyle S(n)=\sum\limits_{k=0}^{n}\binom{n}{k}k^n$. You are given, $S(10)=142469423360$. Find $S(10^{18})$. Submit your answer modulo $83^3 89^3 97^3$.
<p> Let $\displaystyle S(n)=\sum\limits_{k=0}^{n}\binom{n}{k}k^n$.</p> <p> You are given, $S(10)=142469423360$.</p> <p> Find $S(10^{18})$. Submit your answer modulo $83^3 89^3 97^3$.</p>
https://projecteuler.net/problem=830
254179446930484376
831
Let $g(m)$ be the integer defined by the following double sum of products of binomial coefficients: $$\sum_{j=0}^m\sum_{i = 0}^j (-1)^{j-i}\binom mj \binom ji \binom{j+5+6i}{j+5}.$$ You are given that $g(10) = 127278262644918$. Its first (most significant) five digits are $12727$. Find the first ten digits of $g(142857)$ when written in base $7$.
<p>Let $g(m)$ be the integer defined by the following double sum of products of binomial coefficients:</p> <p> $$\sum_{j=0}^m\sum_{i = 0}^j (-1)^{j-i}\binom mj \binom ji \binom{j+5+6i}{j+5}.$$ </p> <p> You are given that $g(10) = 127278262644918$.<br> Its first (most significant) five digits are $12727$.<br> Find the first ten digits of $g(142857)$ when written in base $7$. </p>
https://projecteuler.net/problem=831
5226432553
832
In this problem $\oplus$ is used to represent the bitwise exclusive or of two numbers. Starting with blank paper repeatedly do the following: - Write down the smallest positive integer $a$ which is currently not on the paper; - Find the smallest positive integer $b$ such that neither $b$ nor $(a \oplus b)$ is currently on the paper. Then write down both $b$ and $(a \oplus b)$. After the first round $\{1,2,3\}$ will be written on the paper. In the second round $a=4$ and because $(4 \oplus 5)$, $(4 \oplus 6)$ and $(4 \oplus 7)$ are all already written $b$ must be $8$. After $n$ rounds there will be $3n$ numbers on the paper. Their sum is denoted by $M(n)$. For example, $M(10) = 642$ and $M(1000) = 5432148$. Find $M(10^{18})$. Give your answer modulo $1\,000\,000\,007$.
<p> In this problem $\oplus$ is used to represent the bitwise <strong>exclusive or</strong> of two numbers.<br> Starting with blank paper repeatedly do the following:</p> <ol type="1"> <li>Write down the smallest positive integer $a$ which is currently not on the paper;</li> <li>Find the smallest positive integer $b$ such that neither $b$ nor $(a \oplus b)$ is currently on the paper. Then write down both $b$ and <span style="white-space:nowrap;">$(a \oplus b)$.</span></li> </ol> <p> After the first round $\{1,2,3\}$ will be written on the paper. In the second round $a=4$ and because <span style="white-space:nowrap;">$(4 \oplus 5)$,</span> $(4 \oplus 6)$ and $(4 \oplus 7)$ are all already written $b$ must be <span style="white-space:nowrap;">$8$.</span></p> <p> After $n$ rounds there will be $3n$ numbers on the paper. Their sum is denoted by <span style="white-space:nowrap;">$M(n)$.</span><br> For example, $M(10) = 642$ and <span style="white-space:nowrap;">$M(1000) = 5432148$.</span></p> <p> Find <span style="white-space:nowrap;">$M(10^{18})$.</span> Give your answer modulo <span style="white-space:nowrap;">$1\,000\,000\,007$.</span></p>
https://projecteuler.net/problem=832
552839586
833
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&lt;c \le n$, $c^2=T_a \cdot T_b$ and $0&lt;a&lt;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>
https://projecteuler.net/problem=833
43884302
834
A sequence is created by starting with a positive integer $n$ and incrementing by $(n+m)$ at the $m^{th}$ step. If $n=10$, the resulting sequence will be $21,33,46,60,75,91,108,126,\ldots$. Let $S(n)$ be the set of indices $m$, for which the $m^{th}$ term in the sequence is divisible by $(n+m)$. For example, $S(10)=\{5,8,20,35,80\}$. Define $T(n)$ to be the sum of the indices in $S(n)$. For example, $T(10) = 148$ and $T(10^2)=21828$. Let $\displaystyle U(N)=\sum_{n=3}^{N}T(n)$. You are given, $U(10^2)=612572$. Find $U(1234567)$.
<p> A sequence is created by starting with a positive integer $n$ and incrementing by $(n+m)$ at the $m^{th}$ step. If $n=10$, the resulting sequence will be $21,33,46,60,75,91,108,126,\ldots$.</p> <p> Let $S(n)$ be the set of indices $m$, for which the $m^{th}$ term in the sequence is divisible by $(n+m)$.<br> For example, $S(10)=\{5,8,20,35,80\}$.</p> <p> Define $T(n)$ to be the sum of the indices in $S(n)$. For example, $T(10) = 148$ and $T(10^2)=21828$.</p> <p> Let $\displaystyle U(N)=\sum_{n=3}^{N}T(n)$. You are given, $U(10^2)=612572$.</p> <p> Find $U(1234567)$.</p>
https://projecteuler.net/problem=834
1254404167198752370
835
A Pythagorean triangle is called supernatural if two of its three sides are consecutive integers. Let $S(N)$ be the sum of the perimeters of all distinct supernatural triangles with perimeters less than or equal to $N$. For example, $S(100) = 258$ and $S(10000) = 172004$. Find $S(10^{10^{10}})$. Give your answer modulo $1234567891$.
<p> A <strong>Pythagorean triangle</strong> is called <dfn>supernatural</dfn> if two of its three sides are consecutive<span style="white-space:nowrap;"> integers.</span> </p> <p> Let $S(N)$ be the sum of the perimeters of all distinct supernatural triangles with perimeters less than or equal <span style="white-space:nowrap;"> to $N$.</span><br> For example, $S(100) = 258$ and <span style="white-space:nowrap;"> $S(10000) = 172004$.</span> </p> <p> Find $S(10^{10^{10}})$. Give your answer modulo $1234567891$. </p>
https://projecteuler.net/problem=835
1050923942
836
Let $A$ be an affine plane over a radically integral local field $F$ with residual characteristic $p$. We consider an open oriented line section $U$ of $A$ with normalized Haar measure $m$. Define $f(m, p)$ as the maximal possible discriminant of the jacobian associated to the orthogonal kernel embedding of $U$ into $A$. Find $f(20230401, 57)$. Give as your answer the concatenation of the first letters of each bolded word.
<p>Let $A$ be an <b>affine plane</b> over a <b>radically integral local field</b> $F$ with residual characteristic $p$.</p> <p>We consider an <b>open oriented line section</b> $U$ of $A$ with normalized Haar measure $m$.</p> <p>Define $f(m, p)$ as the maximal possible discriminant of the <b>jacobian</b> associated to the <b>orthogonal kernel embedding</b> of $U$ <span style="white-space:nowrap;">into $A$.</span></p> <p>Find $f(20230401, 57)$. Give as your answer the concatenation of the first letters of each bolded word.</p>
https://projecteuler.net/problem=836
aprilfoolsjoke
837
Amidakuji (Japanese: 阿弥陀籤) is a method for producing a random permutation of a set of objects. In the beginning, a number of parallel vertical lines are drawn, one for each object. Then a specified number of horizontal rungs are added, each lower than any previous rungs. Each rung is drawn as a line segment spanning a randomly select pair of adjacent vertical lines. For example, the following diagram depicts an Amidakuji with three objects ($A$, $B$, $C$) and six rungs: The coloured lines in the diagram illustrate how to form the permutation. For each object, starting from the top of its vertical line, trace downwards but follow any rung encountered along the way, and record which vertical we end up on. In this example, the resulting permutation happens to be the identity: $A\mapsto A$, $B\mapsto B$, $C\mapsto C$. Let $a(m, n)$ be the number of different three-object Amidakujis that have $m$ rungs between $A$ and $B$, and $n$ rungs between $B$ and $C$, and whose outcome is the identity permutation. For example, $a(3, 3) = 2$, because the Amidakuji shown above and its mirror image are the only ones with the required property. You are also given that $a(123, 321) \equiv 172633303 \pmod{1234567891}$. Find $a(123456789, 987654321)$. Give your answer modulo $1234567891$.
<p> <a href="https://en.wikipedia.org/wiki/Amidakuji">Amidakuji</a> (Japanese: 阿弥陀籤) is a method for producing a random permutation of a set of objects.</p> <p> In the beginning, a number of parallel vertical lines are drawn, one for each object. Then a specified number of horizontal rungs are added, each lower than any previous rungs. Each rung is drawn as a line segment spanning a randomly select pair of adjacent vertical lines.</p> <p> For example, the following diagram depicts an Amidakuji with three objects ($A$, $B$, $C$) and six rungs:</p> <div style="text-align:center;"> <img src="resources/images/0837_amidakuji.png?1678992054" alt="0837_amidakuji.png"> </div> <p> The coloured lines in the diagram illustrate how to form the permutation. For each object, starting from the top of its vertical line, trace downwards but follow any rung encountered along the way, and record which vertical we end up on. In this example, the resulting permutation happens to be the identity: $A\mapsto A$, $B\mapsto B$, $C\mapsto C$.</p> <p> Let $a(m, n)$ be the number of different three-object Amidakujis that have $m$ rungs between $A$ and $B$, and $n$ rungs between $B$ and $C$, and whose outcome is the identity permutation. For example, $a(3, 3) = 2$, because the Amidakuji shown above and its mirror image are the only ones with the required property.</p> <p> You are also given that $a(123, 321) \equiv 172633303 \pmod{1234567891}$.</p> <p> Find $a(123456789, 987654321)$. Give your answer modulo $1234567891$.</p>
https://projecteuler.net/problem=837
428074856
838
Let $f(N)$ be the smallest positive integer that is not coprime to any positive integer $n \le N$ whose least significant digit is $3$. For example $f(40)$ equals to $897 = 3 \cdot 13 \cdot 23$ since it is not coprime to any of $3,13,23,33$. By taking the natural logarithm (log to base $e$) we obtain $\ln f(40) = \ln 897 \approx 6.799056$ when rounded to six digits after the decimal point. You are also given $\ln f(2800) \approx 715.019337$. Find $f(10^6)$. Enter its natural logarithm rounded to six digits after the decimal point.
<p>Let $f(N)$ be the smallest positive integer that is not coprime to any positive integer $n \le N$ whose least significant digit is $3$.</p> <p>For example $f(40)$ equals to $897 = 3 \cdot 13 \cdot 23$ since it is not coprime to any of $3,13,23,33$. By taking the <b><a href="https://en.wikipedia.org/wiki/Natural_logarithm">natural logarithm</a></b> (log to base $e$) we obtain $\ln f(40) = \ln 897 \approx 6.799056$ when rounded to six digits after the decimal point.</p> <p>You are also given $\ln f(2800) \approx 715.019337$.</p> <p>Find $f(10^6)$. Enter its natural logarithm rounded to six digits after the decimal point.</p>
https://projecteuler.net/problem=838
250591.442792
839
The sequence $S_n$ is defined by $S_0 = 290797$ and $S_n = S_{n - 1}^2 \bmod 50515093$ for $n > 0$. There are $N$ bowls indexed $0,1,\dots ,N-1$. Initially there are $S_n$ beans in bowl $n$. At each step, the smallest index $n$ is found such that bowl $n$ has strictly more beans than bowl $n+1$. Then one bean is moved from bowl $n$ to bowl $n+1$. Let $B(N)$ be the number of steps needed to sort the bowls into non-descending order. For example, $B(5) = 0$, $B(6) = 14263289$ and $B(100)=3284417556$. Find $B(10^7)$.
<p> The sequence $S_n$ is defined by $S_0 = 290797$ and $S_n = S_{n - 1}^2 \bmod 50515093$ for $n &gt; 0$.</p> <p>There are $N$ bowls indexed $0,1,\dots ,N-1$. Initially there are $S_n$ beans in bowl $n$.</p> <p> At each step, the smallest index $n$ is found such that bowl $n$ has strictly more beans than bowl $n+1$. Then one bean is moved from bowl $n$ to bowl $n+1$.</p> <p> Let $B(N)$ be the number of steps needed to sort the bowls into non-descending order.<br> For example, $B(5) = 0$, $B(6) = 14263289$ and $B(100)=3284417556$.</p> <p> Find $B(10^7)$.</p>
https://projecteuler.net/problem=839
150893234438294408
840
A partition of $n$ is a set of positive integers for which the sum equals $n$. The partitions of 5 are: $\{5\},\{1,4\},\{2,3\},\{1,1,3\},\{1,2,2\},\{1,1,1,2\}$ and $\{1,1,1,1,1\}$. Further we define the function $D(p)$ as: $$ \begin{align} \begin{split} D(1) &= 1 \\ D(p) &= 1, \text{ for any prime } p \\ D(pq) &= D(p)q + pD(q), \text{ for any positive integers } p,q \gt 1. \end{split} \end{align} $$ Now let $\{a_1, a_2,\ldots,a_k\}$ be a partition of $n$. We assign to this particular partition the value: $$P=\prod_{j=1}^{k}D(a_j). $$ $G(n)$ is the sum of $P$ for all partitions of $n$. We can verify that $G(10) = 164$. We also define: $$S(N)=\sum_{n=1}^{N}G(n).$$ You are given $S(10)=396$. Find $S(5\times 10^4) \mod 999676999$.
<p>A <strong>partition</strong> of $n$ is a set of positive integers for which the sum equals $n$.<br> The partitions of 5 are:<br> $\{5\},\{1,4\},\{2,3\},\{1,1,3\},\{1,2,2\},\{1,1,1,2\}$ and $\{1,1,1,1,1\}$. </p> <p> Further we define the function $D(p)$ as:<br> $$ \begin{align} \begin{split} D(1) &amp;= 1 \\ D(p) &amp;= 1, \text{ for any prime } p \\ D(pq) &amp;= D(p)q + pD(q), \text{ for any positive integers } p,q \gt 1. \end{split} \end{align} $$ </p> <p> Now let $\{a_1, a_2,\ldots,a_k\}$ be a partition of $n$.<br> We assign to this particular partition the value:<br> $$P=\prod_{j=1}^{k}D(a_j). $$ </p> <p> $G(n)$ is the sum of $P$ for all partitions of $n$.<br> We can verify that $G(10) = 164$. </p> We also define: $$S(N)=\sum_{n=1}^{N}G(n).$$ You are given $S(10)=396$.<br> Find $S(5\times 10^4) \mod 999676999$.
https://projecteuler.net/problem=840
194396971
841
The regular star polygon $\{p/q\}$, for coprime integers $p,q$ with $p \gt 2q \gt 0$, is a polygon formed from $p$ edges of equal length and equal internal angles, such that tracing the complete polygon wraps $q$ times around the centre. For example, $\{8/3\}$ is illustrated below: The edges of a regular star polygon intersect one another, dividing the interior into several regions. Define the alternating shading of a regular star polygon to be a selection of such regions to shade, such that every piece of every edge has a shaded region on one side and an unshaded region on the other, with the exterior of the polygon unshaded. For example, the above image shows the alternating shading (in green) of $\{8/3\}$. Let $A(p, q)$ be the area of the alternating shading of $\{p/q\}$, assuming that its inradius is $1$. (The inradius of a regular polygon, star or otherwise, is the distance from its centre to the midpoint of any of its edges.) For example, in the diagram above, it can be shown that central shaded octagon has area $8(\sqrt{2}-1)$ and each point's shaded kite has area $2(\sqrt{2}-1)$, giving $A(8,3) = 24(\sqrt{2}-1) \approx 9.9411254970$. You are also given that $A(130021, 50008)\approx 10.9210371479$, rounded to $10$ digits after the decimal point. Find $\sum_{n=3}^{34} A(F_{n+1},F_{n-1})$, where $F_j$ is the Fibonacci sequence with $F_1=F_2=1$ (so $A(F_{5+1},F_{5-1}) = A(8,3)$). Give your answer rounded to $10$ digits after the decimal point.
<p>The regular star polygon $\{p/q\}$, for coprime integers $p,q$ with $p \gt 2q \gt 0$, is a polygon formed from $p$ edges of equal length and equal internal angles, such that tracing the complete polygon wraps $q$ times around the centre. For example, $\{8/3\}$ is illustrated below:</p> <div align="center"><img src="resources/images/0841_star_polygon_8_3.png?1680515338" alt="{8/3}" height="250"></div> <p>The edges of a regular star polygon intersect one another, dividing the interior into several regions. Define the <dfn>alternating shading</dfn> of a regular star polygon to be a selection of such regions to shade, such that every piece of every edge has a shaded region on one side and an unshaded region on the other, with the exterior of the polygon unshaded. For example, the above image shows the alternating shading (in green) of $\{8/3\}$.</p> <p>Let $A(p, q)$ be the area of the alternating shading of $\{p/q\}$, assuming that its inradius is $1$. (The <strong>inradius</strong> of a regular polygon, star or otherwise, is the distance from its centre to the midpoint of any of its edges.) For example, in the diagram above, it can be shown that central shaded octagon has area $8(\sqrt{2}-1)$ and each point's shaded kite has area $2(\sqrt{2}-1)$, giving $A(8,3) = 24(\sqrt{2}-1) \approx 9.9411254970$.</p> <p>You are also given that $A(130021, 50008)\approx 10.9210371479$, rounded to $10$ digits after the decimal point.</p> <p>Find $\sum_{n=3}^{34} A(F_{n+1},F_{n-1})$, where $F_j$ is the Fibonacci sequence with $F_1=F_2=1$ (so $A(F_{5+1},F_{5-1}) = A(8,3)$). Give your answer rounded to $10$ digits after the decimal point.</p>
https://projecteuler.net/problem=841
381.7860132854
842
Given $n$ equally spaced points on a circle, we define an $n$-star polygon as an $n$-gon having those $n$ points as vertices. Two $n$-star polygons differing by a rotation/reflection are considered different. For example, there are twelve $5$-star polygons shown below. For an $n$-star polygon $S$, let $I(S)$ be the number of its self intersection points. Let $T(n)$ be the sum of $I(S)$ over all $n$-star polygons $S$. For the example above $T(5) = 20$ because in total there are $20$ self intersection points. Some star polygons may have intersection points made from more than two lines. These are only counted once. For example, $S$, shown below is one of the sixty $6$-star polygons. This one has $I(S) = 4$. You are also given that $T(8) = 14640$. Find $\displaystyle \sum_{n = 3}^{60}T(n)$. Give your answer modulo $(10^9 + 7)$.
<p> Given $n$ equally spaced points on a circle, we define an <dfn>$n$-star polygon</dfn> as an $n$-gon having those $n$ points as vertices. Two $n$-star polygons differing by a rotation/reflection are considered <b>different</b>.</p> <p> For example, there are twelve $5$-star polygons shown below.</p> <img src="resources/images/0842_5-agons.jpg?1680461480" alt="0842_5-agons.jpg"> <p> For an $n$-star polygon $S$, let $I(S)$ be the number of its self intersection points.<br> Let $T(n)$ be the sum of $I(S)$ over all $n$-star polygons $S$.<br> For the example above $T(5) = 20$ because in total there are $20$ self intersection points.</p> <p> Some star polygons may have intersection points made from more than two lines. These are only counted once. For example, <span style="white-space:nowrap;">$S$,</span> shown below is one of the sixty $6$-star polygons. This one has $I(S) = 4$.</p> <img src="resources/images/0842_6-agon.jpg?1680461493" alt="0842_6-agon.jpg"> <p> You are also given that $T(8) = 14640$.</p> <p> Find $\displaystyle \sum_{n = 3}^{60}T(n)$. Give your answer modulo $(10^9 + 7)$.</p>
https://projecteuler.net/problem=842
885226002
843
This problem involves an iterative procedure that begins with a circle of $n\ge 3$ integers. At each step every number is simultaneously replaced with the absolute difference of its two neighbours. For any initial values, the procedure eventually becomes periodic. Let $S(N)$ be the sum of all possible periods for $3\le n \leq N$. For example, $S(6) = 6$, because the possible periods for $3\le n \leq 6$ are $1, 2, 3$. Specifically, $n=3$ and $n=4$ can each have period $1$ only, while $n=5$ can have period $1$ or $3$, and $n=6$ can have period $1$ or $2$. You are also given $S(30) = 20381$. Find $S(100)$.
<p> This problem involves an iterative procedure that begins with a circle of $n\ge 3$ integers. At each step every number is simultaneously replaced with the absolute difference of its two neighbours.</p> <p> For any initial values, the procedure eventually becomes periodic.</p> <p> Let $S(N)$ be the sum of all possible periods for $3\le n \leq N$. For example, $S(6) = 6$, because the possible periods for $3\le n \leq 6$ are $1, 2, 3$. Specifically, $n=3$ and $n=4$ can each have period $1$ only, while $n=5$ can have period $1$ or $3$, and $n=6$ can have period $1$ or $2$.</p> <p> You are also given $S(30) = 20381$.</p> <p> Find $S(100)$.</p>
https://projecteuler.net/problem=843
2816775424692
844
Consider positive integer solutions to $a^2+b^2+c^2 = 3abc$ For example, $(1,5,13)$ is a solution. We define a 3-Markov number to be any part of a solution, so $1$, $5$ and $13$ are all 3-Markov numbers. Adding distinct 3-Markov numbers $\le 10^3$ would give $2797$. Now we define a $k$-Markov number to be a positive integer that is part of a solution to: $\displaystyle \sum_{i=1}^{k}x_i^2=k\prod_{i=1}^{k}x_i,\quad x_i\text{ are positive integers}$ Let $M_k(N)$ be the sum of $k$-Markov numbers $\le N$. Hence $M_3(10^{3})=2797$, also $M_8(10^8) = 131493335$. Define $\displaystyle S(K,N)=\sum_{k=3}^{K}M_k(N)$. You are given $S(4, 10^2)=229$ and $S(10, 10^8)=2383369980$. Find $S(10^{18}, 10^{18})$. Give your answer modulo $1\,405\,695\,061$.
<p>Consider positive integer solutions to</p> <center>$a^2+b^2+c^2 = 3abc$</center> <p>For example, $(1,5,13)$ is a solution. We define a 3-Markov number to be any part of a solution, so $1$, $5$ and $13$ are all 3-Markov numbers. Adding distinct 3-Markov numbers $\le 10^3$ would give $2797$.</p> <p>Now we define a $k$-Markov number to be a positive integer that is part of a solution to:</p> <center>$\displaystyle \sum_{i=1}^{k}x_i^2=k\prod_{i=1}^{k}x_i,\quad x_i\text{ are positive integers}$</center> <p>Let $M_k(N)$ be the sum of $k$-Markov numbers $\le N$. Hence $M_3(10^{3})=2797$, also $M_8(10^8) = 131493335$.</p> <p>Define $\displaystyle S(K,N)=\sum_{k=3}^{K}M_k(N)$. You are given $S(4, 10^2)=229$ and $S(10, 10^8)=2383369980$.</p> <p>Find $S(10^{18}, 10^{18})$. Give your answer modulo $1\,405\,695\,061$.</p>
https://projecteuler.net/problem=844
101805206
845
Let $D(n)$ be the $n$-th positive integer that has the sum of its digits a prime. For example, $D(61) = 157$ and $D(10^8) = 403539364$. Find $D(10^{16})$.
<p> Let $D(n)$ be the $n$-th positive integer that has the sum of its digits a prime.<br> For example, $D(61) = 157$ and $D(10^8) = 403539364$.</p> <p> Find $D(10^{16})$.</p>
https://projecteuler.net/problem=845
45009328011709400
846
A bracelet is made by connecting at least three numbered beads in a circle. Each bead can only display $1$, $2$, or any number of the form $p^k$ or $2p^k$ for odd prime $p$. In addition a magic bracelet must satisfy the following two conditions: - no two beads display the same number - the product of the numbers of any two adjacent beads is of the form $x^2+1$ Define the potency of a magic bracelet to be the sum of numbers on its beads. The example is a magic bracelet with five beads which has a potency of 155. Let $F(N)$ be the sum of the potency of each magic bracelet which can be formed using positive integers not exceeding $N$, where rotations and reflections of an arrangement are considered equivalent. You are given $F(20)=258$ and $F(10^2)=538768$. Find $F(10^6)$.
<p> A <i>bracelet</i> is made by connecting at least three numbered beads in a circle. Each bead can only display $1$, $2$, or any number of the form $p^k$ or $2p^k$ for odd prime $p$.</p> <p> In addition a <i>magic bracelet</i> must satisfy the following two conditions:</p> <ul> <li> no two beads display the same number</li> <li> the product of the numbers of any two adjacent beads is of the form $x^2+1$</li> </ul> <div style="text-align:center;"> <img src="resources/images/0846_diagram.jpg?1684224225" alt="0846_diagram.jpg" width="640" height="225"> </div> <p> Define the <i>potency</i> of a magic bracelet to be the sum of numbers on its beads. </p> <p> The example is a magic bracelet with five beads which has a potency of 155. </p> <p> Let $F(N)$ be the sum of the potency of each magic bracelet which can be formed using positive integers not exceeding $N$, where rotations and reflections of an arrangement are considered equivalent. You are given $F(20)=258$ and $F(10^2)=538768$.</p> <p> Find $F(10^6)$.</p>
https://projecteuler.net/problem=846
9851175623
847
Jack has three plates in front of him. The giant has $N$ beans that he distributes to the three plates. All the beans look the same, but one of them is a magic bean. Jack doesn't know which one it is, but the giant knows. Jack can ask the giant questions of the form: "Does this subset of the beans contain the magic bean?" In each question Jack may choose any subset of beans from a single plate, and the giant will respond truthfully. If the three plates contain $a$, $b$ and $c$ beans respectively, we let $h(a, b, c)$ be the minimal number of questions Jack needs to ask in order to guarantee he locates the magic bean. For example, $h(1, 2, 3) = 3$ and $h(2, 3, 3) = 4$. Let $H(N)$ be the sum of $h(a, b, c)$ over all triples of non-negative integers $a$, $b$, $c$ with $1 \leq a + b + c \leq N$. You are given: $H(6) = 203$ and $H(20) = 7718$. A repunit, $R_n$, is a number made up with $n$ digits all '1'. For example, $R_3 = 111$ and $H(R_3) = 1634144$. Find $H(R_{19})$. Give your answer modulo $1\,000\,000\,007$.
<p> Jack has three plates in front of him. The giant has $N$ beans that he distributes to the three plates. All the beans look the same, but one of them is a magic bean. Jack doesn't know which one it is, but the giant knows.</p> <p> Jack can ask the giant questions of the form: "Does this subset of the beans contain the magic bean?" In each question Jack may choose any subset of beans from a single plate, and the giant will respond truthfully.</p> <p> If the three plates contain $a$, $b$ and $c$ beans respectively, we let $h(a, b, c)$ be the minimal number of questions Jack needs to ask in order to guarantee he locates the magic bean. For example, $h(1, 2, 3) = 3$ and $h(2, 3, 3) = 4$.</p> <p> Let $H(N)$ be the sum of $h(a, b, c)$ over all triples of non-negative integers $a$, $b$, $c$ with $1 \leq a + b + c \leq N$.<br> You are given: $H(6) = 203$ and $H(20) = 7718$.</p> <p> A <strong>repunit</strong>, $R_n$, is a number made up with $n$ digits all '1'. For example, $R_3 = 111$ and $H(R_3) = 1634144$.</p> <p> Find $H(R_{19})$. Give your answer modulo $1\,000\,000\,007$.</p>
https://projecteuler.net/problem=847
381868244
848
Two players play a game. At the start of the game each player secretly chooses an integer; the first player from $1,...,n$ and the second player from $1,...,m$. Then they take alternate turns, starting with the first player. The player, whose turn it is, displays a set of numbers and the other player tells whether their secret number is in the set or not. The player to correctly guess a set with a single number is the winner and the game ends. Let $p(m,n)$ be the winning probability of the first player assuming both players play optimally. For example $p(1, n) = 1$ and $p(m, 1) = 1/m$. You are also given $p(7,5) \approx 0.51428571$. Find $\displaystyle \sum_{i=0}^{20}\sum_{j=0}^{20} p(7^i, 5^j)$ and give your answer rounded to 8 digits after the decimal point.
<p>Two players play a game. At the start of the game each player secretly chooses an integer; the first player from $1,...,n$ and the second player from $1,...,m$. Then they take alternate turns, starting with the first player. The player, whose turn it is, displays a set of numbers and the other player tells whether their secret number is in the set or not. The player to correctly guess a set with a single number is the winner and the game ends.</p> <p>Let $p(m,n)$ be the winning probability of the first player assuming both players play optimally. For example $p(1, n) = 1$ and $p(m, 1) = 1/m$.</p> <p>You are also given $p(7,5) \approx 0.51428571$.</p> <p>Find $\displaystyle \sum_{i=0}^{20}\sum_{j=0}^{20} p(7^i, 5^j)$ and give your answer rounded to 8 digits after the decimal point.</p>
https://projecteuler.net/problem=848
188.45503259
849
In a tournament there are $n$ teams and each team plays each other team twice. A team gets two points for a win, one point for a draw and no points for a loss. With two teams there are three possible outcomes for the total points. $(4,0)$ where a team wins twice, $(3,1)$ where a team wins and draws, and $(2,2)$ where either there are two draws or a team wins one game and loses the other. Here we do not distinguish the teams and so $(3,1)$ and $(1,3)$ are considered identical. Let $F(n)$ be the total number of possible final outcomes with $n$ teams, so that $F(2) = 3$. You are also given $F(7) = 32923$. Find $F(100)$. Give your answer modulo $10^9+7$.
<p> In a tournament there are $n$ teams and each team plays each other team twice. A team gets two points for a win, one point for a draw and no points for a loss.</p> <p> With two teams there are three possible outcomes for the total points. $(4,0)$ where a team wins twice, $(3,1)$ where a team wins and draws, and $(2,2)$ where either there are two draws or a team wins one game and loses the other. Here we do not distinguish the teams and so $(3,1)$ and $(1,3)$ are considered identical.</p> <p> Let $F(n)$ be the total number of possible final outcomes with $n$ teams, so that $F(2) = 3$.<br> You are also given $F(7) = 32923$.</p> <p> Find $F(100)$. Give your answer modulo $10^9+7$.</p>
https://projecteuler.net/problem=849
936203459
850
Any positive real number $x$ can be decomposed into integer and fractional parts $\lfloor x \rfloor + \{x\}$, where $\lfloor x \rfloor$ (the floor function) is an integer, and $0\le \{x\} < 1$. For positive integers $k$ and $n$, define the function $$\begin{align} f_k(n) = \sum_{i=1}^{n}\left\{ \frac{i^k}{n} \right\} \end{align}$$ For example, $f_5(10)=4.5$ and $f_7(1234)=616.5$. Let $$\begin{align} S(N) = \sum_{\substack{k=1 \\ k\text{ odd}}}^{N} \sum_{n=1}^{N} f_k(n) \end{align}$$ You are given that $S(10)=100.5$ and $S(10^3)=123687804$. Find $\lfloor S(33557799775533) \rfloor$. Give your answer modulo 977676779.
<p>Any positive real number $x$ can be decomposed into integer and fractional parts $\lfloor x \rfloor + \{x\}$, where $\lfloor x \rfloor$ (the floor function) is an integer, and $0\le \{x\} &lt; 1$.</p> <p>For positive integers $k$ and $n$, define the function $$\begin{align} f_k(n) = \sum_{i=1}^{n}\left\{ \frac{i^k}{n} \right\} \end{align}$$ For example, $f_5(10)=4.5$ and $f_7(1234)=616.5$.</p> <p>Let $$\begin{align} S(N) = \sum_{\substack{k=1 \\ k\text{ odd}}}^{N} \sum_{n=1}^{N} f_k(n) \end{align}$$ You are given that $S(10)=100.5$ and $S(10^3)=123687804$.</p> <p>Find $\lfloor S(33557799775533) \rfloor$. Give your answer modulo 977676779.</p>
https://projecteuler.net/problem=850
878255725
851
Let $n$ be a positive integer and let $E_n$ be the set of $n$-tuples of strictly positive integers. For $u = (u_1, \cdots, u_n)$ and $v = (v_1, \cdots, v_n)$ two elements of $E_n$, we define: - the Sum Of Products of $u$ and $v$, denoted by $\langle u, v\rangle$, as the sum $\displaystyle\sum_{i = 1}^n u_i v_i$; - the Product Of Sums of $u$ and $v$, denoted by $u \star v$, as the product $\displaystyle\prod_{i = 1}^n (u_i + v_i)$. Let $R_n(M)$ be the sum of $u \star v$ over all ordered pairs $(u, v)$ in $E_n$ such that $\langle u, v\rangle = M$. For example: $R_1(10) = 36$, $R_2(100) = 1873044$, $R_2(100!) \equiv 446575636 \bmod 10^9 + 7$. Find $R_6(10000!)$. Give your answer modulo $10^9+7$.
<p> Let $n$ be a positive integer and let $E_n$ be the set of $n$-tuples of strictly positive integers.</p> <p> For $u = (u_1, \cdots, u_n)$ and $v = (v_1, \cdots, v_n)$ two elements of $E_n$, we define:</p> <ul> <li>the <dfn>Sum Of Products</dfn> of $u$ and $v$, denoted by $\langle u, v\rangle$, as the sum $\displaystyle\sum_{i = 1}^n u_i v_i$;</li> <li>the <dfn>Product Of Sums</dfn> of $u$ and $v$, denoted by $u \star v$, as the product $\displaystyle\prod_{i = 1}^n (u_i + v_i)$.</li></ul> <p> Let $R_n(M)$ be the sum of $u \star v$ over all ordered pairs $(u, v)$ in $E_n$ such that $\langle u, v\rangle = M$.<br> For example: $R_1(10) = 36$, $R_2(100) = 1873044$, $R_2(100!) \equiv 446575636 \bmod 10^9 + 7$.</p> <p> Find $R_6(10000!)$. Give your answer modulo $10^9+7$.</p>
https://projecteuler.net/problem=851
726358482
852
This game has a box of $N$ unfair coins and $N$ fair coins. Fair coins have probability 50% of landing heads while unfair coins have probability 75% of landing heads. The player begins with a score of 0 which may become negative during play. At each round the player randomly picks a coin from the box and guesses its type: fair or unfair. Before guessing they may toss the coin any number of times; however, each toss subtracts 1 from their score. The decision to stop tossing and make a guess can be made at any time. After guessing the player's score is increased by 20 if they are right and decreased by 50 if they are wrong. Then the coin type is revealed to the player and the coin is discarded. After $2N$ rounds the box will be empty and the game is over. Let $S(N)$ be the expected score of the player at the end of the game assuming that they play optimally in order to maximize their expected score. You are given $S(1) = 20.558591$ rounded to 6 digits after the decimal point. Find $S(50)$. Give your answer rounded to 6 digits after the decimal point.
<p>This game has a box of $N$ unfair coins and $N$ fair coins. Fair coins have probability 50% of landing heads while unfair coins have probability 75% of landing heads.</p> <p>The player begins with a score of 0 which may become negative during play.</p> <p>At each round the player randomly picks a coin from the box and guesses its type: fair or unfair. Before guessing they may toss the coin any number of times; however, each toss subtracts 1 from their score. The decision to stop tossing and make a guess can be made at any time. After guessing the player's score is increased by 20 if they are right and decreased by 50 if they are wrong. Then the coin type is revealed to the player and the coin is discarded.</p> <p>After $2N$ rounds the box will be empty and the game is over. Let $S(N)$ be the expected score of the player at the end of the game assuming that they play optimally in order to maximize their expected score.</p> <p>You are given $S(1) = 20.558591$ rounded to 6 digits after the decimal point.</p> <p>Find $S(50)$. Give your answer rounded to 6 digits after the decimal point.</p>
https://projecteuler.net/problem=852
130.313496
853
For every positive integer $n$ the Fibonacci sequence modulo $n$ is periodic. The period depends on the value of $n$. This period is called the Pisano period for $n$, often shortened to $\pi(n)$. There are three values of $n$ for which $\pi(n)$ equals $18$: $19$, $38$ and $76$. The sum of those smaller than $50$ is $57$. Find the sum of the values of $n$ smaller than $1\,000\,000\,000$ for which $\pi(n)$ equals $120$.
<p> For every positive integer $n$ the Fibonacci sequence modulo $n$ is periodic. The period depends on the value of $n$. This period is called the <strong>Pisano period</strong> for $n$, often shortened to $\pi(n)$.</p> <p> There are three values of $n$ for which $\pi(n)$ equals $18$: $19$, $38$ and $76$. The sum of those smaller than $50$ is $57$. </p> <p> Find the sum of the values of $n$ smaller than $1\,000\,000\,000$ for which $\pi(n)$ equals $120$. </p>
https://projecteuler.net/problem=853
44511058204
854
For every positive integer $n$ the Fibonacci sequence modulo $n$ is periodic. The period depends on the value of $n$. This period is called the Pisano period for $n$, often shortened to $\pi(n)$. Define $M(p)$ as the largest integer $n$ such that $\pi(n) = p$, and define $M(p) = 1$ if there is no such $n$. For example, there are three values of $n$ for which $\pi(n)$ equals $18$: $19, 38, 76$. Therefore $M(18) = 76$. Let the product function $P(n)$ be: $$P(n)=\prod_{p = 1}^{n}M(p).$$ You are given: $P(10)=264$. Find $P(1\,000\,000)\bmod 1\,234\,567\,891$.
<p> For every positive integer $n$ the Fibonacci sequence modulo $n$ is periodic. The period depends on the value of $n$. This period is called the <strong>Pisano period</strong> for $n$, often shortened to $\pi(n)$.</p> <p> Define $M(p)$ as the largest integer $n$ such that $\pi(n) = p$, and define $M(p) = 1$ if there is no such $n$.<br> For example, there are three values of $n$ for which $\pi(n)$ equals $18$: $19, 38, 76$. Therefore $M(18) = 76$.</p> <p> Let the product function $P(n)$ be: $$P(n)=\prod_{p = 1}^{n}M(p).$$ You are given: $P(10)=264$.</p> <p> Find $P(1\,000\,000)\bmod 1\,234\,567\,891$.</p>
https://projecteuler.net/problem=854
29894398
855
Given two positive integers $a,b$, Alex and Bianca play a game in $ab$ rounds. They begin with a square piece of paper of side length $1$. In each round Alex divides the current rectangular piece of paper into $a \times b$ pieces using $a-1$ horizontal cuts and $b-1$ vertical ones. The cuts do not need to be evenly spaced. Moreover, a piece can have zero width/height when a cut coincides with another cut or the edge of the paper. The pieces are then numbered $1, 2, ..., ab$ starting from the left top corner, moving from left to right and starting from the left of the next row when a row is finished. Then Bianca chooses one of the pieces for the game to continue on. However, Bianca must not choose a piece with a number she has already chosen during the game. Bianca wants to minimize the area of the final piece of paper while Alex wants to maximize it. Let $S(a,b)$ be the area of the final piece assuming optimal play. For example, $S(2,2) = 1/36$ and $S(2, 3) = 1/1800 \approx 5.5555555556\mathrm {e}{-4}$. Find $S(5,8)$. Give your answer in scientific notation rounded to ten significant digits after the decimal point. Use a lowercase e to separate the mantissa and the exponent.
<p>Given two positive integers $a,b$, Alex and Bianca play a game in $ab$ rounds. They begin with a square piece of paper of side length $1$.</p> <p>In each round Alex divides the current rectangular piece of paper into $a \times b$ pieces using $a-1$ horizontal cuts and $b-1$ vertical ones. The cuts do not need to be evenly spaced. Moreover, a piece can have zero width/height when a cut coincides with another cut or the edge of the paper. The pieces are then numbered $1, 2, ..., ab$ starting from the left top corner, moving from left to right and starting from the left of the next row when a row is finished.</p> <p>Then Bianca chooses one of the pieces for the game to continue on. However, Bianca must not choose a piece with a number she has already chosen during the game.</p> <p>Bianca wants to minimize the area of the final piece of paper while Alex wants to maximize it. Let $S(a,b)$ be the area of the final piece assuming optimal play.</p> <p>For example, $S(2,2) = 1/36$ and $S(2, 3) = 1/1800 \approx 5.5555555556\mathrm {e}{-4}$.</p> <p>Find $S(5,8)$. Give your answer in scientific notation rounded to ten significant digits after the decimal point. Use a lowercase e to separate the mantissa and the exponent.</p>
https://projecteuler.net/problem=855
6.8827571976e-57
856
A standard 52-card deck comprises 13 ranks in four suits. A pair is a set of two cards of the same rank. Cards are drawn, without replacement, from a well shuffled 52-card deck waiting for consecutive cards that form a pair. For example, the probability of finding a pair in the first two draws is $\frac{1}{17}$. Cards are drawn until either such a pair is found or the pack is exhausted waiting for one. In the latter case we say that all 52 cards were drawn. Find the expected number of cards that were drawn. Give your answer rounded to eight places after the decimal point.
<p>A standard 52-card deck comprises 13 ranks in four suits. A <i>pair</i> is a set of two cards of the same rank.</p> <p>Cards are drawn, without replacement, from a well shuffled 52-card deck waiting for consecutive cards that form a pair. For example, the probability of finding a pair in the first two draws is $\frac{1}{17}$.</p> <p>Cards are drawn until either such a pair is found or the pack is exhausted waiting for one. In the latter case we say that all 52 cards were drawn.</p> <p>Find the expected number of cards that were drawn. Give your answer rounded to eight places after the decimal point.</p>
https://projecteuler.net/problem=856
17.09661501
857
A graph is made up of vertices and coloured edges. Between every two distinct vertices there must be exactly one of the following: - A red directed edge one way, and a blue directed edge the other way - A green undirected edge - A brown undirected edge Such a graph is called beautiful if - A cycle of edges contains a red edge if and only if it also contains a blue edge - No triangle of edges is made up of entirely green or entirely brown edges Below are four distinct examples of beautiful graphs on three vertices: Below are four examples of graphs that are not beautiful: Let $G(n)$ be the number of beautiful graphs on the labelled vertices: $1,2,\ldots,n$. You are given $G(3)=24$, $G(4)=186$ and $G(15)=12472315010483328$. Find $G(10^7)$. Give your answer modulo $10^9+7$.
<p> A graph is made up of vertices and coloured edges. Between every two distinct vertices there must be exactly one of the following:</p> <ul> <li>A red directed edge one way, and a blue directed edge the other way</li> <li>A green undirected edge</li> <li>A brown undirected edge</li> </ul> Such a graph is called <i>beautiful</i> if <ul> <li>A cycle of edges contains a red edge <b>if and only if</b> it also contains a blue edge</li> <li>No triangle of edges is made up of entirely green or entirely brown edges</li> </ul> <p> Below are four distinct examples of beautiful graphs on three vertices: </p> <img src="resources/images/0857_GoodGraphs.jpg?1692412187" alt="0857_GoodGraphs.jpg"> <p> Below are four examples of graphs that are not beautiful:</p> <img src="resources/images/0857_BadGraphs.jpg?1692412205" alt="0857_BadGraphs.jpg"> <p> Let $G(n)$ be the number of beautiful graphs on the labelled vertices: $1,2,\ldots,n$. You are given $G(3)=24$, $G(4)=186$ and $G(15)=12472315010483328$.</p> <p> Find $G(10^7)$. Give your answer modulo $10^9+7$.</p>
https://projecteuler.net/problem=857
966332096
858
Define $G(N) = \sum_S \operatorname{lcm}(S)$ where $S$ ranges through all subsets of $\{1, \dots, N\}$ and $\operatorname{lcm}$ denotes the lowest common multiple. Note that the $\operatorname{lcm}$ of the empty set is $1$. You are given $G(5) = 528$ and $G(20) = 8463108648960$. Find $G(800)$. Give your answer modulo $10^9 + 7$.
<p> Define $G(N) = \sum_S \operatorname{lcm}(S)$ where $S$ ranges through all subsets of $\{1, \dots, N\}$ and $\operatorname{lcm}$ denotes the lowest common multiple. Note that the $\operatorname{lcm}$ of the empty set is $1$.</p> <p> You are given $G(5) = 528$ and $G(20) = 8463108648960$.</p> <p> Find $G(800)$. Give your answer modulo $10^9 + 7$.</p>
https://projecteuler.net/problem=858
973077199
859
Odd and Even are playing a game with $N$ cookies. The game begins with the $N$ cookies divided into one or more piles, not necessarily of the same size. They then make moves in turn, starting with Odd. Odd's turn: Odd may choose any pile with an odd number of cookies, eat one and divide the remaining (if any) into two equal piles. Even's turn: Even may choose any pile with an even number of cookies, eat two of them and divide the remaining (if any) into two equal piles. The player that does not have a valid move loses the game. Let $C(N)$ be the number of ways that $N$ cookies can be divided so that Even has a winning strategy. For example, $C(5) = 2$ because there are two winning configurations for Even: a single pile containing all five cookies; three piles containing one, two and two cookies. You are also given $C(16) = 64$. Find $C(300)$.
<p> Odd and Even are playing a game with $N$ cookies.</p> <p> The game begins with the $N$ cookies divided into one or more piles, not necessarily of the same size. They then make moves in turn, starting with Odd.<br> Odd's turn: Odd may choose any pile with an <b>odd</b> number of cookies, eat one and divide the remaining (if any) into two equal piles.<br> Even's turn: Even may choose any pile with an <b>even</b> number of cookies, eat two of them and divide the remaining (if any) into two equal piles.<br> The player that does not have a valid move loses the game.</p> <p> Let $C(N)$ be the number of ways that $N$ cookies can be divided so that Even has a winning strategy.<br> For example, $C(5) = 2$ because there are two winning configurations for Even: a single pile containing all five cookies; three piles containing one, two and two cookies.<br> You are also given $C(16) = 64$.</p> <p> Find $C(300)$.</p>
https://projecteuler.net/problem=859
1527162658488196
860
Gary and Sally play a game using gold and silver coins arranged into a number of vertical stacks, alternating turns. On Gary's turn he chooses a gold coin and removes it from the game along with any other coins sitting on top. Sally does the same on her turn by removing a silver coin. The first player unable to make a move loses. An arrangement is called fair if the person moving first, whether it be Gary or Sally, will lose the game if both play optimally. Define $F(n)$ to be the number of fair arrangements of $n$ stacks, all of size $2$. Different orderings of the stacks are to be counted separately, so $F(2) = 4$ due to the following four arrangements: You are also given $F(10) = 63594$. Find $F(9898)$. Give your answer modulo $989898989$
<p> Gary and Sally play a game using gold and silver coins arranged into a number of vertical stacks, alternating turns. On Gary's turn he chooses a gold coin and removes it from the game along with any other coins sitting on top. Sally does the same on her turn by removing a silver coin. The first player unable to make a move loses.</p> <p> An arrangement is called <dfn>fair</dfn> if the person moving first, whether it be Gary or Sally, will lose the game if both play optimally.</p> <p> Define $F(n)$ to be the number of fair arrangements of $n$ stacks, all of size $2$. Different orderings of the stacks are to be counted separately, so $F(2) = 4$ due to the following four arrangements:</p> <div class="center"> <img src="resources/images/0860_diag3.jpg?1696883006" alt="0860_diag3.jpg"> </div> <p> You are also given $F(10) = 63594$.</p> <p> Find $F(9898)$. Give your answer modulo $989898989$</p>
https://projecteuler.net/problem=860
958666903
861
A unitary divisor of a positive integer $n$ is a divisor $d$ of $n$ such that $\gcd\left(d,\frac{n}{d}\right)=1$. A bi-unitary divisor of $n$ is a divisor $d$ for which $1$ is the only unitary divisor of $d$ that is also a unitary divisor of $\frac{n}{d}$. For example, $2$ is a bi-unitary divisor of $8$, because the unitary divisors of $2$ are $\{1,2\}$, and the unitary divisors of $8/2$ are $\{1,4\}$, with $1$ being the only unitary divisor in common. The bi-unitary divisors of $240$ are $\{1,2,3,5,6,8,10,15,16,24,30,40,48,80,120,240\}$. Let $P(n)$ be the product of all bi-unitary divisors of $n$. Define $Q_k(N)$ as the number of positive integers $1 \lt n \leq N$ such that $P(n)=n^k$. For example, $Q_2\left(10^2\right)=51$ and $Q_6\left(10^6\right)=6189$. Find $\sum_{k=2}^{10}Q_k\left(10^{12}\right)$.
<p>A <i>unitary divisor</i> of a positive integer $n$ is a divisor $d$ of $n$ such that $\gcd\left(d,\frac{n}{d}\right)=1$.</p> <p>A <i>bi-unitary divisor</i> of $n$ is a divisor $d$ for which $1$ is the only unitary divisor of $d$ that is also a unitary divisor of $\frac{n}{d}$.</p> <p>For example, $2$ is a bi-unitary divisor of $8$, because the unitary divisors of $2$ are $\{1,2\}$, and the unitary divisors of $8/2$ are $\{1,4\}$, with $1$ being the only unitary divisor in common.</p> <p>The bi-unitary divisors of $240$ are $\{1,2,3,5,6,8,10,15,16,24,30,40,48,80,120,240\}$.</p> <p>Let $P(n)$ be the product of all bi-unitary divisors of $n$. Define $Q_k(N)$ as the number of positive integers $1 \lt n \leq N$ such that $P(n)=n^k$. For example, $Q_2\left(10^2\right)=51$ and $Q_6\left(10^6\right)=6189$.</p> <p>Find $\sum_{k=2}^{10}Q_k\left(10^{12}\right)$.</p>
https://projecteuler.net/problem=861
672623540591
862
For a positive integer $n$ define $T(n)$ to be the number of strictly larger integers which can be formed by permuting the digits of $n$. Leading zeros are not allowed and so for $n = 2302$ the total list of permutations would be: $2023,2032,2203,2230,\mathbf{2302},2320,3022,32 02,3220$ giving $T(2302)=4$. Further define $S(k)$ to be the sum of $T(n)$ for all $k$-digit numbers $n$. You are given $S(3) = 1701$. Find $S(12)$.
<p> For a positive integer $n$ define $T(n)$ to be the number of strictly larger integers which can be formed by permuting the digits of $n$.</p> <p> Leading zeros are not allowed and so for $n = 2302$ the total list of permutations would be:</p> <div style="text-align:center;"> $2023,2032,2203,2230,\mathbf{2302},2320,3022,32 02,3220$</div> <p> giving $T(2302)=4$.</p> <p> Further define $S(k)$ to be the sum of $T(n)$ for all $k$-digit numbers $n$. You are given $S(3) = 1701$.</p> <p> Find $S(12)$.</p>
https://projecteuler.net/problem=862
6111397420935766740
863
Using only a six-sided fair dice and a five-sided fair dice, we would like to emulate an $n$-sided fair dice. For example, one way to emulate a 28-sided dice is to follow this procedure: - Roll both dice, obtaining integers $1\le p\le 6$ and $1\le q\le 5$. - Combine them using $r = 5(p-1) + q$ to obtain an integer $1\le r\le 30$. - If $r\le 28$, return the value $r$ and stop. - Otherwise ($r$ being 29 or 30), roll both dice again, obtaining integers $1\le s\le 6$ and $1\le t\le 5$. - Compute $u = 30(r-29) + 5(s-1) + t$ to obtain an integer $1\le u\le 60$. - If $u>4$, return the value $((u-5)\bmod 28) + 1$ and stop. - Otherwise (with $1\le u\le 4$), roll the six-sided dice twice, obtaining integers $1\le v\le 6$ and $1\le w\le 6$. - Compute $x = 36(u-1) + 6(v-1) + w$ to obtain an integer $1\le x\le 144$. - If $x>4$, return the value $((x-5)\bmod 28) + 1$ and stop. - Otherwise (with $1\le x\le 4$), assign $u:=x$ and go back to step 7. The expected number of dice rolls in following this procedure is 2.142476 (rounded to 6 decimal places). Note that rolling both dice at the same time is still counted as two dice rolls. There exist other more complex procedures for emulating a 28-sided dice that entail a smaller average number of dice rolls. However, the above procedure has the attractive property that the sequence of dice rolled is predetermined: regardless of the outcome, it follows (D5,D6,D5,D6,D6,D6,D6,...), truncated wherever the process stops. In fact, amongst procedures for $n=28$ with this restriction, this one is optimal in the sense of minimising the expected number of rolls needed. Different values of $n$ will in general use different predetermined sequences. For example, for $n=8$, the sequence (D5,D5,D5,...) gives an optimal procedure, taking 2.083333... dice rolls on average. Define $R(n)$ to be the expected number of dice rolls for an optimal procedure for emulating an $n$-sided dice using only a five-sided and a six-sided dice, considering only those procedures where the sequence of dice rolled is predetermined. So, $R(8) \approx 2.083333$ and $R(28) \approx 2.142476$. Let $S(n) = \displaystyle\sum_{k=2}^n R(k)$. You are given that $S(30) \approx 56.054622$. Find $S(1000)$. Give your answer rounded to 6 decimal places.
<p>Using only a six-sided fair dice and a five-sided fair dice, we would like to emulate an $n$-sided fair dice.</p> <p>For example, one way to emulate a 28-sided dice is to follow this procedure:</p> <ol> <li>Roll both dice, obtaining integers $1\le p\le 6$ and $1\le q\le 5$.</li> <li>Combine them using $r = 5(p-1) + q$ to obtain an integer $1\le r\le 30$.</li> <li>If $r\le 28$, return the value $r$ and stop.</li> <li>Otherwise ($r$ being 29 or 30), roll both dice again, obtaining integers $1\le s\le 6$ and $1\le t\le 5$.</li> <li>Compute $u = 30(r-29) + 5(s-1) + t$ to obtain an integer $1\le u\le 60$.</li> <li>If $u&gt;4$, return the value $((u-5)\bmod 28) + 1$ and stop.</li> <li>Otherwise (with $1\le u\le 4$), roll the six-sided dice twice, obtaining integers $1\le v\le 6$ and $1\le w\le 6$.</li> <li>Compute $x = 36(u-1) + 6(v-1) + w$ to obtain an integer $1\le x\le 144$.</li> <li>If $x&gt;4$, return the value $((x-5)\bmod 28) + 1$ and stop.</li> <li>Otherwise (with $1\le x\le 4$), assign $u:=x$ and go back to step 7.</li> </ol> <p>The expected number of dice rolls in following this procedure is 2.142476 (rounded to 6 decimal places). Note that rolling both dice at the same time is still counted as two dice rolls.</p> <p>There exist other more complex procedures for emulating a 28-sided dice that entail a smaller average number of dice rolls. However, the above procedure has the attractive property that the sequence of dice rolled is predetermined: regardless of the outcome, it follows (D5,D6,D5,D6,D6,D6,D6,...), truncated wherever the process stops. In fact, amongst procedures for $n=28$ with this restriction, this one is optimal in the sense of minimising the expected number of rolls needed.</p> <p>Different values of $n$ will in general use different predetermined sequences. For example, for $n=8$, the sequence (D5,D5,D5,...) gives an optimal procedure, taking 2.083333... dice rolls on average.</p> <p>Define $R(n)$ to be the expected number of dice rolls for an optimal procedure for emulating an $n$-sided dice using only a five-sided and a six-sided dice, considering only those procedures where the sequence of dice rolled is predetermined. So, $R(8) \approx 2.083333$ and $R(28) \approx 2.142476$.</p> <p>Let $S(n) = \displaystyle\sum_{k=2}^n R(k)$. You are given that $S(30) \approx 56.054622$.</p> <p>Find $S(1000)$. Give your answer rounded to 6 decimal places.</p>
https://projecteuler.net/problem=863
3862.871397
864
Let $C(n)$ be the number of squarefree integers of the form $x^2 + 1$ such that $1 \le x \le n$. For example, $C(10) = 9$ and $C(1000) = 895$. Find $C(123567101113)$.
<p>Let $C(n)$ be the number of squarefree integers of the form $x^2 + 1$ such that $1 \le x \le n$.</p> <p>For example, $C(10) = 9$ and $C(1000) = 895$.</p> <p>Find $C(123567101113)$.</p>
https://projecteuler.net/problem=864
110572936177
865
A triplicate number is a positive integer such that, after repeatedly removing three consecutive identical digits from it, all its digits can be removed. For example, the integer $122555211$ is a triplicate number: $$122{\color{red}555}211 \rightarrow 1{\color{red}222}11\rightarrow{\color{red}111}\rightarrow.$$ On the other hand, neither $663633$ nor $9990$ are triplicate numbers. Let $T(n)$ be how many triplicate numbers are less than $10^n$. For example, $T(6) = 261$ and $T(30) = 5576195181577716$. Find $T(10^4)$. Give your answer modulo $998244353$.
<p> A <dfn>triplicate number</dfn> is a positive integer such that, after repeatedly removing three consecutive identical digits from it, all its digits can be removed.</p> <p> For example, the integer $122555211$ is a triplicate number: $$122{\color{red}555}211 \rightarrow 1{\color{red}222}11\rightarrow{\color{red}111}\rightarrow.$$ On the other hand, neither $663633$ nor $9990$ are triplicate numbers.</p> <p> Let $T(n)$ be how many triplicate numbers are less than $10^n$.</p> <p> For example, $T(6) = 261$ and $T(30) = 5576195181577716$.</p> <p> Find $T(10^4)$. Give your answer modulo $998244353$.</p>
https://projecteuler.net/problem=865
761181918
866
A small child has a “number caterpillar” consisting of $N$ jigsaw pieces, each with one number on it, which, when connected together in a line, reveal the numbers $1$ to $N$ in order. Every night, the child's father has to pick up the pieces of the caterpillar that have been scattered across the play room. He picks up the pieces at random and places them in the correct order. As the caterpillar is built up in this way, it forms distinct segments that gradually merge together. Any time the father places a new piece in its correct position, a segment of length $k$ is formed and he writes down the $k$th hexagonal number $k\cdot(2k-1)$. Once all pieces have been placed and the full caterpillar constructed he calculates the product of all the numbers written down. Interestingly, the expected value of this product is always an integer. For example if $N=4$ then the expected value is $994$. Find the expected value of the product for a caterpillar of $N=100$ pieces. Give your answer modulo $987654319$.
<p> A small child has a “number caterpillar” consisting of $N$ jigsaw pieces, each with one number on it, which, when connected together in a line, reveal the numbers $1$ to $N$ in order.</p> <p> Every night, the child's father has to pick up the pieces of the caterpillar that have been scattered across the play room. He picks up the pieces at random and places them in the correct order.<br> As the caterpillar is built up in this way, it forms distinct segments that gradually merge together.</p> <p> Any time the father places a new piece in its correct position, a segment of length $k$ is formed and he writes down the $k$<sup>th</sup> hexagonal number $k\cdot(2k-1)$. Once all pieces have been placed and the full caterpillar constructed he calculates the product of all the numbers written down. Interestingly, the expected value of this product is always an integer. For example if $N=4$ then the expected value is $994$.</p> <p> Find the expected value of the product for a caterpillar of $N=100$ pieces. Give your answer modulo $987654319$.</p>
https://projecteuler.net/problem=866
492401720
867
There are $5$ ways to tile a regular dodecagon of side $1$ with regular polygons of side $1$. Let $T(n)$ be the number of ways to tile a regular dodecagon of side $n$ with regular polygons of side $1$. Then $T(1) = 5$. You are also given $T(2) = 48$. Find $T(10)$. Give your answer modulo $10^9+7$.
<p> There are $5$ ways to tile a regular dodecagon of side $1$ with regular polygons of side $1$.</p> <img src="resources/images/0867_DodecaDiagram.jpg?1700512497" alt="0867_DodecaDiagram.jpg"> <p> Let $T(n)$ be the number of ways to tile a regular dodecagon of side $n$ with regular polygons of side $1$. Then $T(1) = 5$. You are also given $T(2) = 48$.</p> <p> Find $T(10)$. Give your answer modulo $10^9+7$.</p>
https://projecteuler.net/problem=867
870557257
868
There is a method that is used by Bell ringers to generate all variations of the order that bells are rung. The same method can be used to create all permutations of a set of letters. Consider the letters to be permuted initially in order from smallest to largest. At each step swap the largest letter with the letter on its left or right whichever generates a permutation that has not yet been seen. If neither gives a new permutation then try the next largest letter and so on. This procedure continues until all permutations have been generated. For example, $3$ swaps are required to reach the permutation CBA when starting with ABC. The swaps are ABC $\to$ ACB $\to$ CAB $\to$ CBA. Also $59$ swaps are required to reach BELFRY when starting with these letters in alphabetical order. Find the number of swaps that are required to reach NOWPICKBELFRYMATHS when starting with these letters in alphabetical order.
<p> There is a method that is used by Bell ringers to generate all variations of the order that bells are rung.</p> <p> The same method can be used to create all permutations of a set of letters. Consider the letters to be permuted initially in order from smallest to largest. At each step swap the largest letter with the letter on its left or right whichever generates a permutation that has not yet been seen. If neither gives a new permutation then try the next largest letter and so on. This procedure continues until all permutations have been generated.</p><p> </p><p> For example, $3$ swaps are required to reach the permutation CBA when starting with ABC.<br> The swaps are ABC $\to$ ACB $\to$ CAB $\to$ CBA.<br> Also $59$ swaps are required to reach BELFRY when starting with these letters in alphabetical order.</p> <p> Find the number of swaps that are required to reach NOWPICKBELFRYMATHS when starting with these letters in alphabetical order.</p>
https://projecteuler.net/problem=868
3832914911887589
869
A prime is drawn uniformly from all primes not exceeding $N$. The prime is written in binary notation, and a player tries to guess it bit-by-bit starting at the least significant bit. The player scores one point for each bit they guess correctly. Immediately after each guess, the player is informed whether their guess was correct, and also whether it was the last bit in the number - in which case the game is over. Let $E(N)$ be the expected number of points assuming that the player always guesses to maximize their score. For example, $E(10)=2$, achievable by always guessing "1". You are also given $E(30)=2.9$. Find $E(10^8)$. Give your answer rounded to eight digits after the decimal point.
<p> A prime is drawn uniformly from all primes not exceeding $N$. The prime is written in binary notation, and a player tries to guess it bit-by-bit starting at the least significant bit. The player scores one point for each bit they guess correctly. Immediately after each guess, the player is informed whether their guess was correct, and also whether it was the last bit in the number - in which case the game is over.</p> <p> Let $E(N)$ be the expected number of points assuming that the player always guesses to maximize their score. For example, $E(10)=2$, achievable by always guessing "1". You are also given $E(30)=2.9$.</p> <p> Find $E(10^8)$. Give your answer rounded to eight digits after the decimal point.</p>
https://projecteuler.net/problem=869
14.97696693
870
Two players play a game with a single pile of stones of initial size $n$. They take stones from the pile in turn, according to the following rules which depend on a fixed real number $r > 0$: - In the first turn, the first player may take $k$ stones with $1 \le k \lt n$. - If a player takes $m$ stones in a turn, then in the next turn the opponent may take $k$ stones with $1 \le k \le \lfloor r \cdot m \rfloor$. Whoever cannot make a legal move loses the game. Let $L(r)$ be the set of initial pile sizes $n$ for which the second player has a winning strategy. For example, $L(0.5) = \{1\}$, $L(1) = \{1, 2, 4, 8, 16, \dots\}$, $L(2) = \{1, 2, 3, 5, 8, \dots\}$. A real number $q \gt 0$ is a transition value if $L(s)$ is different from $L(t)$ for all $s < q < t$. Let $T(i)$ be the $i$-th transition value. For example, $T(1) = 1$, $T(2) = 2$, $T(22) \approx 6.3043478261$. Find $T(123456)$ and give your answer rounded to $10$ digits after the decimal point.
<p> Two players play a game with a single pile of stones of initial size $n$. They take stones from the pile in turn, according to the following rules which depend on a fixed real number $r &gt; 0$:</p> <ul> <li> In the first turn, the first player may take $k$ stones with $1 \le k \lt n$.</li> <li> If a player takes $m$ stones in a turn, then in the next turn the opponent may take $k$ stones with $1 \le k \le \lfloor r \cdot m \rfloor$.</li></ul> <p> Whoever cannot make a legal move loses the game.</p> <p> Let $L(r)$ be the set of initial pile sizes $n$ for which the second player has a winning strategy. For example, $L(0.5) = \{1\}$, $L(1) = \{1, 2, 4, 8, 16, \dots\}$, $L(2) = \{1, 2, 3, 5, 8, \dots\}$.</p> <p> A real number $q \gt 0$ is a <i>transition value</i> if $L(s)$ is different from $L(t)$ for all $s &lt; q &lt; t$.<br> Let $T(i)$ be the $i$-th transition value. For example, $T(1) = 1$, $T(2) = 2$, $T(22) \approx 6.3043478261$.</p> <p> Find $T(123456)$ and give your answer rounded to $10$ digits after the decimal point.</p>
https://projecteuler.net/problem=870
229.9129353234
871
Let $f$ be a function from a finite set $S$ to itself. A drifting subset for $f$ is a subset $A$ of $S$ such that the number of elements in the union $A \cup f(A)$ is equal to twice the number of elements of $A$. We write $D(f)$ for the maximal number of elements among all drifting subsets for $f$. For a positive integer $n$, define $f_n$ as the function from $\{0, 1, \dots, n - 1\}$ to itself sending $x$ to $x^3 + x + 1 \bmod n$. You are given $D(f_5) = 1$ and $D(f_{10}) = 3$. Find $\displaystyle\sum_{i = 1}^{100} D(f_{10^5 + i})$.
<p> Let $f$ be a function from a finite set $S$ to itself. A <dfn>drifting subset</dfn> for $f$ is a subset $A$ of $S$ such that the number of elements in the union $A \cup f(A)$ is equal to twice the number of elements of $A$.<br> We write $D(f)$ for the maximal number of elements among all drifting subsets for $f$.</p> <p> For a positive integer $n$, define $f_n$ as the function from $\{0, 1, \dots, n - 1\}$ to itself sending $x$ to $x^3 + x + 1 \bmod n$.<br> You are given $D(f_5) = 1$ and $D(f_{10}) = 3$.</p> <p> Find $\displaystyle\sum_{i = 1}^{100} D(f_{10^5 + i})$.</p>
https://projecteuler.net/problem=871
2848790
872
A sequence of rooted trees $T_n$ is constructed such that $T_n$ has $n$ nodes numbered $1$ to $n$. The sequence starts at $T_1$, a tree with a single node as a root with the number $1$. For $n > 1$, $T_n$ is constructed from $T_{n-1}$ using the following procedure: - Trace a path from the root of $T_{n-1}$ to a leaf by following the largest-numbered child at each node. - Remove all edges along the traced path, disconnecting all nodes along it from their parents. - Connect all orphaned nodes directly to a new node numbered $n$, which becomes the root of $T_n$. For example, the following figure shows $T_6$ and $T_7$. The path traced through $T_6$ during the construction of $T_7$ is coloured red. Let $f(n, k)$ be the sum of the node numbers along the path connecting the root of $T_n$ to the node $k$, including the root and the node $k$. For example, $f(6, 1) = 6 + 5 + 1 = 12$ and $f(10, 3) = 29$. Find $f(10^{17}, 9^{17})$.
<p>A sequence of rooted trees $T_n$ is constructed such that $T_n$ has $n$ nodes numbered $1$ to $n$.</p> <p>The sequence starts at $T_1$, a tree with a single node as a root with the number $1$.</p> <p>For $n &gt; 1$, $T_n$ is constructed from $T_{n-1}$ using the following procedure: </p><ol> <li>Trace a path from the root of $T_{n-1}$ to a leaf by following the largest-numbered child at each node.</li> <li>Remove all edges along the traced path, disconnecting all nodes along it from their parents.</li> <li>Connect all orphaned nodes directly to a new node numbered $n$, which becomes the root of $T_n$.</li> </ol> <p>For example, the following figure shows $T_6$ and $T_7$. The path traced through $T_6$ during the construction of $T_7$ is coloured red.</p> <div class="center"> <img src="resources/images/0872_tree.png?1703839264" alt="0872_tree.png"></div> <p>Let $f(n, k)$ be the sum of the node numbers along the path connecting the root of $T_n$ to the node $k$, including the root and the node $k$. For example, $f(6, 1) = 6 + 5 + 1 = 12$ and $f(10, 3) = 29$.</p> <p>Find $f(10^{17}, 9^{17})$.</p>
https://projecteuler.net/problem=872
2903144925319290239
873
Let $W(p,q,r)$ be the number of words that can be formed using the letter A $p$ times, the letter B $q$ times and the letter C $r$ times with the condition that every A is separated from every B by at least two Cs. For example, CACACCBB is a valid word for $W(2,2,4)$ but ACBCACBC is not. You are given $W(2,2,4)=32$ and $W(4,4,44)=13908607644$. Find $W(10^6,10^7,10^8)$. Give your answer modulo $1\,000\,000\,007$.
<p> Let $W(p,q,r)$ be the number of words that can be formed using the letter A $p$ times, the letter B $q$ times and the letter C $r$ times with the condition that every A is separated from every B by at least two Cs. For example, CACACCBB is a valid word for $W(2,2,4)$ but ACBCACBC is not.</p> <p> You are given $W(2,2,4)=32$ and $W(4,4,44)=13908607644$.</p> <p> Find $W(10^6,10^7,10^8)$. Give your answer modulo $1\,000\,000\,007$.</p>
https://projecteuler.net/problem=873
735131856
874
Let $p(t)$ denote the $(t+1)$th prime number. So that $p(0) = 2$, $p(1) = 3$, etc. We define the prime score of a list of nonnegative integers $[a_1, \dots, a_n]$ as the sum $\sum_{i = 1}^n p(a_i)$. Let $M(k, n)$ be the maximal prime score among all lists $[a_1, \dots, a_n]$ such that: - $0 \leq a_i < k$ for each $i$; - the sum $\sum_{i = 1}^n a_i$ is a multiple of $k$. For example, $M(2, 5) = 14$ as $[0, 1, 1, 1, 1]$ attains a maximal prime score of $14$. Find $M(7000, p(7000))$.
<p> Let $p(t)$ denote the $(t+1)$th prime number. So that $p(0) = 2$, $p(1) = 3$, etc.<br> We define the <dfn>prime score</dfn> of a list of nonnegative integers $[a_1, \dots, a_n]$ as the sum $\sum_{i = 1}^n p(a_i)$.<br> Let $M(k, n)$ be the maximal prime score among all lists $[a_1, \dots, a_n]$ such that:</p> <ul> <li> $0 \leq a_i &lt; k$ for each $i$; </li><li> the sum $\sum_{i = 1}^n a_i$ is a multiple of $k$. </li></ul> <p> For example, $M(2, 5) = 14$ as $[0, 1, 1, 1, 1]$ attains a maximal prime score of $14$.</p> <p> Find $M(7000, p(7000))$.</p>
https://projecteuler.net/problem=874
4992775389
875
For a positive integer $n$ we define $q(n)$ to be the number of solutions to: $$a_1^2+a_2^2+a_3^2+a_4^2 \equiv b_1^2+b_2^2+b_3^2+b_4^2 \pmod n$$ where $0 \leq a_i, b_i \lt n$. For example, $q(4)= 18432$. Define $\displaystyle Q(n)=\sum_{i=1}^{n}q(i)$. You are given $Q(10)=18573381$. Find $Q(12345678)$. Give your answer modulo $1001961001$.
<p> For a positive integer $n$ we define $q(n)$ to be the number of solutions to:</p> $$a_1^2+a_2^2+a_3^2+a_4^2 \equiv b_1^2+b_2^2+b_3^2+b_4^2 \pmod n$$ <p>where $0 \leq a_i, b_i \lt n$. For example, $q(4)= 18432$.</p> <p> Define $\displaystyle Q(n)=\sum_{i=1}^{n}q(i)$. You are given $Q(10)=18573381$.</p> <p> Find $Q(12345678)$. Give your answer modulo $1001961001$.</p>
https://projecteuler.net/problem=875
79645946
876
Starting with three numbers $a, b, c$, at each step do one of the three operations: - change $a$ to $2(b + c) - a$; - change $b$ to $2(c + a) - b$; - change $c$ to $2(a + b) - c$; Define $f(a, b, c)$ to be the minimum number of steps required for one number to become zero. If this is not possible then $f(a, b, c)=0$. For example, $f(6,10,35)=3$: $$(6,10,35) \to (6,10,-3) \to (8,10,-3) \to (8,0,-3).$$ However, $f(6,10,36)=0$ as no series of operations leads to a zero number. Also define $F(a, b)=\sum_{c=1}^\infty f(a,b,c)$. You are given $F(6,10)=17$ and $F(36,100)=179$. Find $\displaystyle\sum_{k=1}^{18}F(6^k,10^k)$.
<p> Starting with three numbers $a, b, c$, at each step do one of the three operations:</p> <ul> <li>change $a$ to $2(b + c) - a$; </li><li>change $b$ to $2(c + a) - b$; </li><li>change $c$ to $2(a + b) - c$; </li></ul> <p> Define $f(a, b, c)$ to be the minimum number of steps required for one number to become zero. If this is not possible then $f(a, b, c)=0$.</p> <p> For example, $f(6,10,35)=3$: $$(6,10,35) \to (6,10,-3) \to (8,10,-3) \to (8,0,-3).$$ However, $f(6,10,36)=0$ as no series of operations leads to a zero number.</p> <p> Also define $F(a, b)=\sum_{c=1}^\infty f(a,b,c)$. You are given $F(6,10)=17$ and $F(36,100)=179$.</p> <p> Find $\displaystyle\sum_{k=1}^{18}F(6^k,10^k)$.</p>
https://projecteuler.net/problem=876
457019806569269
877
We use $x\oplus y$ for the bitwise XOR of $x$ and $y$. Define the XOR-product of $x$ and $y$, denoted by $x \otimes y$, similar to a long multiplication in base $2$, except that the intermediate results are XORed instead of the usual integer addition. For example, $7 \otimes 3 = 9$, or in base $2$, $111_2 \otimes 11_2 = 1001_2$: $$\begin{align*} \phantom{\otimes 111} 111_2 \\ \otimes \phantom{1111} 11_2 \\ \hline \phantom{\otimes 111} 111_2 \\ \oplus \phantom{11} 111_2 \phantom{9} \\ \hline \phantom{\otimes 11} 1001_2 \\ \end{align*}$$ We consider the equation: $$\begin{align} (a \otimes a) \oplus (2 \otimes a \otimes b) \oplus (b \otimes b) = 5 \end{align}$$ For example, $(a, b) = (3, 6)$ is a solution. Let $X(N)$ be the XOR of the $b$ values for all solutions to this equation satisfying $0 \le a \le b \le N$. You are given $X(10)=5$. Find $X(10^{18})$.
<p> We use $x\oplus y$ for the bitwise XOR of $x$ and $y$.<br> Define the <dfn>XOR-product</dfn> of $x$ and $y$, denoted by $x \otimes y$, similar to a long multiplication in base $2$, except that the intermediate results are XORed instead of the usual integer addition. </p> <p> For example, $7 \otimes 3 = 9$, or in base $2$, $111_2 \otimes 11_2 = 1001_2$: </p><center> $$\begin{align*} \phantom{\otimes 111} 111_2 \\ \otimes \phantom{1111} 11_2 \\ \hline \phantom{\otimes 111} 111_2 \\ \oplus \phantom{11} 111_2 \phantom{9} \\ \hline \phantom{\otimes 11} 1001_2 \\ \end{align*}$$ </center> We consider the equation: <center> $$\begin{align} (a \otimes a) \oplus (2 \otimes a \otimes b) \oplus (b \otimes b) = 5 \end{align}$$ </center> For example, $(a, b) = (3, 6)$ is a solution. <p> Let $X(N)$ be the XOR of the $b$ values for all solutions to this equation satisfying $0 \le a \le b \le N$.<br> You are given $X(10)=5$. </p> <p> Find $X(10^{18})$. </p>
https://projecteuler.net/problem=877
336785000760344621
878
We use $x\oplus y$ for the bitwise XOR of $x$ and $y$. Define the XOR-product of $x$ and $y$, denoted by $x \otimes y$, similar to a long multiplication in base $2$, except that the intermediate results are XORed instead of the usual integer addition. For example, $7 \otimes 3 = 9$, or in base $2$, $111_2 \otimes 11_2 = 1001_2$: $$\begin{align*} \phantom{\otimes 111} 111_2 \\ \otimes \phantom{1111} 11_2 \\ \hline \phantom{\otimes 111} 111_2 \\ \oplus \phantom{11} 111_2 \phantom{9} \\ \hline \phantom{\otimes 11} 1001_2 \\ \end{align*}$$ We consider the equation: $$\begin{align} (a \otimes a) \oplus (2 \otimes a \otimes b) \oplus (b \otimes b) = k. \end{align}$$ For example, $(a, b) = (3, 6)$ is a solution to this equation for $k=5$. Let $G(N,m)$ be the number of solutions to those equations with $k \le m$ and $0 \le a \le b \le N$. You are given $G(1000,100)=398$. Find $G(10^{17},1\,000\,000).$
We use $x\oplus y$ for the bitwise XOR of $x$ and $y$.<br> Define the <dfn>XOR-product</dfn> of $x$ and $y$, denoted by $x \otimes y$, similar to a long multiplication in base $2$, except that the intermediate results are XORed instead of the usual integer addition.<br> For example, $7 \otimes 3 = 9$, or in base $2$, $111_2 \otimes 11_2 = 1001_2$: <center> $$\begin{align*} \phantom{\otimes 111} 111_2 \\ \otimes \phantom{1111} 11_2 \\ \hline \phantom{\otimes 111} 111_2 \\ \oplus \phantom{11} 111_2 \phantom{9} \\ \hline \phantom{\otimes 11} 1001_2 \\ \end{align*}$$ </center> We consider the equation: <center> $$\begin{align} (a \otimes a) \oplus (2 \otimes a \otimes b) \oplus (b \otimes b) = k. \end{align}$$ </center> <p> For example, $(a, b) = (3, 6)$ is a solution to this equation for $k=5$. </p> <p> Let $G(N,m)$ be the number of solutions to those equations with $k \le m$ and $0 \le a \le b \le N$.</p> <p> You are given $G(1000,100)=398$. </p><p> Find $G(10^{17},1\,000\,000).$ </p>
https://projecteuler.net/problem=878
23707109
879
A touch-screen device can be unlocked with a "password" consisting of a sequence of two or more distinct spots that the user selects from a rectangular grid of spots on the screen. The user enters their sequence by touching the first spot, then tracing a straight line segment to the next spot, and so on until the end of the sequence. The user's finger remains in contact with the screen throughout, and may only move in straight line segments from spot to spot. If the finger traces a straight line that passes over an intermediate spot, then that is treated as two line segments with the intermediate spot included in the password sequence. For example, on a $3\times 3$ grid labelled with digits $1$ to $9$ (shown below), tracing $1-9$ is interpreted as $1-5-9$. Once a spot has been selected it disappears from the screen. Thereafter, the spot may not be used as an endpoint of future line segments, and it is ignored by any future line segments which happen to pass through it. For example, tracing $1-9-3-7$ (which crosses the $5$ spot twice) will give the password $1-5-9-6-3-7$. There are $389488$ different passwords that can be formed on a $3 \times 3$ grid. Find the number of different passwords that can be formed on a $4 \times 4$ grid.
<p>A touch-screen device can be unlocked with a "password" consisting of a sequence of two or more distinct spots that the user selects from a rectangular grid of spots on the screen. The user enters their sequence by touching the first spot, then tracing a straight line segment to the next spot, and so on until the end of the sequence. The user's finger remains in contact with the screen throughout, and may only move in straight line segments from spot to spot.</p> <p>If the finger traces a straight line that passes over an intermediate spot, then that is treated as two line segments with the intermediate spot included in the password sequence. For example, on a $3\times 3$ grid labelled with digits $1$ to $9$ (shown below), tracing $1-9$ is interpreted as $1-5-9$.</p> <p>Once a spot has been selected it disappears from the screen. Thereafter, the spot may not be used as an endpoint of future line segments, and it is ignored by any future line segments which happen to pass through it. For example, tracing $1-9-3-7$ (which crosses the $5$ spot twice) will give the password $1-5-9-6-3-7$.</p> <img src="resources/images/0879_touchscreen_159637.png?1707555645" alt="1-5-9-6-3-7 example"> <p>There are $389488$ different passwords that can be formed on a $3 \times 3$ grid.</p> <p>Find the number of different passwords that can be formed on a $4 \times 4$ grid.</p>
https://projecteuler.net/problem=879
4350069824940
880
$(x,y)$ is called a nested radical pair if $x$ and $y$ are non-zero integers such that $\dfrac{x}{y}$ is not a cube of a rational number, and there exist integers $a$, $b$ and $c$ such that: $$\sqrt{\sqrt[3]{x}+\sqrt[3]{y}}=\sqrt[3]{a}+\sqrt[3]{b}+\sqrt[3]{c}$$ For example, both $(-4,125)$ and $(5,5324)$ are nested radical pairs: $$ \begin{align*} \begin{split} \sqrt{\sqrt[3]{-4}+\sqrt[3]{125}} &= \sqrt[3]{-1}+\sqrt[3]{2}+\sqrt[3]{4}\\ \sqrt{\sqrt[3]{5}+\sqrt[3]{5324}} &= \sqrt[3]{-2}+\sqrt[3]{20}+\sqrt[3]{25}\\ \end{split} \end{align*} $$ Let $H(N)$ be the sum of $|x|+|y|$ for all the nested radical pairs $(x, y)$ where $|x| \leq |y|\leq N$. For example, $H(10^3)=2535$. Find $H(10^{15})$. Give your answer modulo $1031^3+2$.
<p>$(x,y)$ is called a <i>nested radical pair</i> if $x$ and $y$ are non-zero integers such that $\dfrac{x}{y}$ is not a cube of a rational number, and there exist integers $a$, $b$ and $c$ such that:</p> $$\sqrt{\sqrt[3]{x}+\sqrt[3]{y}}=\sqrt[3]{a}+\sqrt[3]{b}+\sqrt[3]{c}$$ <p>For example, both $(-4,125)$ and $(5,5324)$ are nested radical pairs:</p> $$ \begin{align*} \begin{split} \sqrt{\sqrt[3]{-4}+\sqrt[3]{125}} &amp;= \sqrt[3]{-1}+\sqrt[3]{2}+\sqrt[3]{4}\\ \sqrt{\sqrt[3]{5}+\sqrt[3]{5324}} &amp;= \sqrt[3]{-2}+\sqrt[3]{20}+\sqrt[3]{25}\\ \end{split} \end{align*} $$ <p>Let $H(N)$ be the sum of $|x|+|y|$ for all the nested radical pairs $(x, y)$ where $|x| \leq |y|\leq N$.<br> For example, $H(10^3)=2535$.</p> <p>Find $H(10^{15})$. Give your answer modulo $1031^3+2$.</p>
https://projecteuler.net/problem=880
522095328
881
For a positive integer $n$ create a graph using its divisors as vertices. An edge is drawn between two vertices $a \lt b$ if their quotient $b/a$ is prime. The graph can be arranged into levels where vertex $n$ is at level $0$ and vertices that are a distance $k$ from $n$ are on level $k$. Define $g(n)$ to be the maximum number of vertices in a single level. The example above shows that $g(45) = 2$. You are also given $g(5040) = 12$. Find the smallest number, $n$, such that $g(n) \ge 10^4$.
<p> For a positive integer $n$ create a graph using its divisors as vertices. An edge is drawn between two vertices $a \lt b$ if their quotient $b/a$ is prime. The graph can be arranged into levels where vertex $n$ is at level $0$ and vertices that are a distance $k$ from $n$ are on level $k$. Define $g(n)$ to be the maximum number of vertices in a single level. </p> <img src="resources/images/0881_example45.jpg?1707508801" alt="0881_example45.jpg"> <p> The example above shows that $g(45) = 2$. You are also given $g(5040) = 12$.</p> <p> Find the smallest number, $n$, such that $g(n) \ge 10^4$.</p>
https://projecteuler.net/problem=881
205702861096933200
882
Dr. One and Dr. Zero are playing the following partisan game. The game begins with one $1$, two $2$'s, three $3$'s, ..., $n$ $n$'s. Starting with Dr. One, they make moves in turn. Dr. One chooses a number and changes it by removing a $1$ from its binary expansion. Dr. Zero chooses a number and changes it by removing a $0$ from its binary expansion. The player that is unable to move loses. Note that leading zeros are not allowed in any binary expansion; in particular nobody can make a move on the number $0$. They soon realize that Dr. Zero can never win the game. In order to make it more interesting, Dr. Zero is allowed to "skip the turn" several times, i.e. passing the turn back to Dr. One without making a move. For example, when $n = 2$, Dr. Zero can win the game if allowed to skip $2$ turns. A sample game: $$ [1, 2, 2]\xrightarrow{\textrm{Dr. One}}[1, 0, 2]\xrightarrow{\textrm{Dr. Zero}}[1, 0, 1]\xrightarrow{\textrm{Dr. One}}[1, 0, 0]\xrightarrow[\textrm{skip}]{\textrm{Dr. Zero}} [1, 0, 0]\xrightarrow{\textrm{Dr. One}}[0, 0, 0]\xrightarrow[\textrm{skip}]{\textrm{Dr. Zero}}[0, 0, 0]. $$ Let $S(n)$ be the minimal number of skips needed so that Dr. Zero has a winning strategy. For example, $S(2) = 2$, $S(5) = 17$, $S(10) = 64$. Find $S(10^5)$.
<p>Dr. One and Dr. Zero are playing the following partisan game.<br> The game begins with one $1$, two $2$'s, three $3$'s, ..., $n$ $n$'s. Starting with Dr. One, they make moves in turn.<br> Dr. One chooses a number and changes it by removing a $1$ from its binary expansion.<br> Dr. Zero chooses a number and changes it by removing a $0$ from its binary expansion.<br> The player that is unable to move loses.<br> Note that leading zeros are not allowed in any binary expansion; in particular nobody can make a move on the number $0$.</p> <p>They soon realize that Dr. Zero can never win the game. In order to make it more interesting, Dr. Zero is allowed to "skip the turn" several times, i.e. passing the turn back to Dr. One without making a move.</p> <p>For example, when $n = 2$, Dr. Zero can win the game if allowed to skip $2$ turns. A sample game: $$ [1, 2, 2]\xrightarrow{\textrm{Dr. One}}[1, 0, 2]\xrightarrow{\textrm{Dr. Zero}}[1, 0, 1]\xrightarrow{\textrm{Dr. One}}[1, 0, 0]\xrightarrow[\textrm{skip}]{\textrm{Dr. Zero}} [1, 0, 0]\xrightarrow{\textrm{Dr. One}}[0, 0, 0]\xrightarrow[\textrm{skip}]{\textrm{Dr. Zero}}[0, 0, 0]. $$ Let $S(n)$ be the minimal number of skips needed so that Dr. Zero has a winning strategy.<br> For example, $S(2) = 2$, $S(5) = 17$, $S(10) = 64$.</p> <p>Find $S(10^5)$.</p>
https://projecteuler.net/problem=882
15800662276
883
In this problem we consider triangles drawn on a hexagonal lattice, where each lattice point in the plane has six neighbouring points equally spaced around it, all distance $1$ away. We call a triangle remarkable if - All three vertices and its incentre lie on lattice points - At least one of its angles is $60^\circ$ Above are four examples of remarkable triangles, with $60^\circ$ angles illustrated in red. Triangles A and B have inradius $1$; C has inradius $\sqrt{3}$; D has inradius $2$. Define $T(r)$ to be the number of remarkable triangles with inradius $\le r$. Rotations and reflections, such as triangles A and B above, are counted separately; however direct translations are not. That is, the same triangle drawn in different positions of the lattice is only counted once. You are given $T(0.5)=2$, $T(2)=44$, and $T(10)=1302$. Find $T(10^6)$.
<p> In this problem we consider triangles drawn on a <b>hexagonal lattice</b>, where each lattice point in the plane has six neighbouring points equally spaced around it, all distance $1$ away.</p> <p> We call a triangle <i>remarkable</i> if</p> <ul> <li>All three vertices and its <b>incentre</b> lie on lattice points</li> <li>At least one of its angles is $60^\circ$</li> </ul> <img src="resources/images/0883_diagram.png?1707941179" alt="0883_diagram.png"> <p> Above are four examples of remarkable triangles, with $60^\circ$ angles illustrated in red. Triangles A and B have inradius $1$; C has inradius $\sqrt{3}$; D has inradius $2$.</p> <p> Define $T(r)$ to be the number of remarkable triangles with inradius $\le r$. Rotations and reflections, such as triangles A and B above, are counted separately; however direct translations are not. That is, the same triangle drawn in different positions of the lattice is only counted once.</p> <p> You are given $T(0.5)=2$, $T(2)=44$, and $T(10)=1302$.</p> <p> Find $T(10^6)$.</p>
https://projecteuler.net/problem=883
14854003484704
884
Starting from a positive integer $n$, at each step we subtract from $n$ the largest perfect cube not exceeding $n$, until $n$ becomes $0$. For example, with $n = 100$ the procedure ends in $4$ steps: $$100 \xrightarrow{-4^3} 36 \xrightarrow{-3^3} 9 \xrightarrow{-2^3} 1 \xrightarrow{-1^3} 0.$$ Let $D(n)$ denote the number of steps of the procedure. Thus $D(100) = 4$. Let $S(N)$ denote the sum of $D(n)$ for all positive integers $n$ strictly less than $N$. For example, $S(100) = 512$. Find $S(10^{17})$.
<p> Starting from a positive integer $n$, at each step we subtract from $n$ the largest perfect cube not exceeding $n$, until $n$ becomes $0$.<br> For example, with $n = 100$ the procedure ends in $4$ steps: $$100 \xrightarrow{-4^3} 36 \xrightarrow{-3^3} 9 \xrightarrow{-2^3} 1 \xrightarrow{-1^3} 0.$$ Let $D(n)$ denote the number of steps of the procedure. Thus $D(100) = 4$.</p> <p> Let $S(N)$ denote the sum of $D(n)$ for all positive integers $n$ <b>strictly less</b> than $N$.<br> For example, $S(100) = 512$.</p> <p> Find $S(10^{17})$.</p>
https://projecteuler.net/problem=884
1105985795684653500
885
For a positive integer $d$, let $f(d)$ be the number created by sorting the digits of $d$ in ascending order, removing any zeros. For example, $f(3403) = 334$. Let $S(n)$ be the sum of $f(d)$ for all positive integers $d$ of $n$ digits or less. You are given $S(1) = 45$ and $S(5) = 1543545675$. Find $S(18)$. Give your answer modulo $1123455689$.
<p> For a positive integer $d$, let $f(d)$ be the number created by sorting the digits of $d$ in ascending order, removing any zeros. For example, $f(3403) = 334$.</p> <p> Let $S(n)$ be the sum of $f(d)$ for all positive integers $d$ of $n$ digits or less. You are given $S(1) = 45$ and $S(5) = 1543545675$.</p> <p> Find $S(18)$. Give your answer modulo $1123455689$.</p>
https://projecteuler.net/problem=885
827850196
886
A permutation of $\{2,3,\ldots,n\}$ is a rearrangement of these numbers. A coprime permutation is a rearrangement such that all pairs of adjacent numbers are coprime. Let $P(n)$ be the number of coprime permutations of $\{2,3,\ldots,n\}$. For example, $P(4)=2$ as there are two coprime permutations, $(2,3,4)$ and $(4,3,2)$. You are also given $P(10)=576$. Find $P(34)$ and give your answer modulo $83\,456\,729$.
<p>A permutation of $\{2,3,\ldots,n\}$ is a rearrangement of these numbers. A <i>coprime permutation</i> is a rearrangement such that all pairs of adjacent numbers are coprime.</p> <p>Let $P(n)$ be the number of coprime permutations of $\{2,3,\ldots,n\}$.</p> <p>For example, $P(4)=2$ as there are two coprime permutations, $(2,3,4)$ and $(4,3,2)$. You are also given $P(10)=576$.</p> <p>Find $P(34)$ and give your answer modulo $83\,456\,729$.</p>
https://projecteuler.net/problem=886
5570163
887
Consider the problem of determining a secret number from a set $\{1, ..., N\}$ by repeatedly choosing a number $y$ and asking "Is the secret number greater than $y$?". If $N=1$ then no questions need to be asked. If $N=2$ then only one question needs to be asked. If $N=64$ then six questions need to be asked. However, in the latter case if the secret number is $1$ then six questions still need to be asked. We want to restrict the number of questions asked for small values. Let $Q(N, d)$ be the least number of questions needed for a strategy that can find any secret number from the set $\{1, ..., N\}$ where no more than $x + d$ questions are needed to find the secret value $x$. It can be proved that $Q(N, 0) = N - 1$. You are also given $Q(7, 1) = 3$ and $Q(777, 2) = 10$. Find $\displaystyle \sum_{d=0}^7 \sum_{N=1}^{7^{10}} Q(N, d)$.
<p>Consider the problem of determining a secret number from a set $\{1, ..., N\}$ by repeatedly choosing a number $y$ and asking "Is the secret number greater than $y$?".</p> <p>If $N=1$ then no questions need to be asked. If $N=2$ then only one question needs to be asked. If $N=64$ then six questions need to be asked. However, in the latter case if the secret number is $1$ then six questions still need to be asked. We want to restrict the number of questions asked for small values.</p> <p>Let $Q(N, d)$ be the least number of questions needed for a strategy that can find any secret number from the set $\{1, ..., N\}$ where no more than $x + d$ questions are needed to find the secret value $x$.</p> <p>It can be proved that $Q(N, 0) = N - 1$. You are also given $Q(7, 1) = 3$ and $Q(777, 2) = 10$.</p> <p>Find $\displaystyle \sum_{d=0}^7 \sum_{N=1}^{7^{10}} Q(N, d)$.</p>
https://projecteuler.net/problem=887
39896187138661622
888
Two players play a game with a number of piles of stones, alternating turns. Each turn a player can choose to remove 1, 2, 4, or 9 stones from a single pile; or alternatively they can choose to split a pile containing two or more stones into two non-empty piles. The winner is the player who removes the last stone. A collection of piles is called a losing position if the player to move cannot force a win with optimal play. Define $S(N, m)$ to be the number of distinct losing positions arising from $m$ piles of stones where each pile contains from $1$ to $N$ stones. Two positions are considered equivalent if they consist of the same pile sizes. That is, the order of the piles does not matter. You are given $S(12,4)=204$ and $S(124,9)=2259208528408$. Find $S(12491249,1249)$. Give your answer modulo $912491249$.
<p> Two players play a game with a number of piles of stones, alternating turns. Each turn a player can choose to remove 1, 2, 4, or 9 stones from a single pile; or alternatively they can choose to split a pile containing two or more stones into two non-empty piles. The winner is the player who removes the last stone.</p> <p> A collection of piles is called a losing position if the player to move cannot force a win with optimal play. Define $S(N, m)$ to be the number of distinct losing positions arising from $m$ piles of stones where each pile contains from $1$ to $N$ stones. Two positions are considered equivalent if they consist of the same pile sizes. That is, the order of the piles does not matter.</p> <p> You are given $S(12,4)=204$ and $S(124,9)=2259208528408$.</p> <p> Find $S(12491249,1249)$. Give your answer modulo $912491249$.</p>
https://projecteuler.net/problem=888
227429102
889
Recall the blancmange function from Problem 226: $T(x) = \sum\limits_{n = 0}^\infty\dfrac{s(2^nx)}{2^n}$, where $s(x)$ is the distance from $x$ to the nearest integer. For positive integers $k, t, r$, we write $$F(k, t, r) = (2^{2k} - 1)T\left(\frac{(2^t + 1)^r}{2^k + 1}\right).$$ It can be shown that $F(k, t, r)$ is always an integer. For example, $F(3, 1, 1) = 42$, $F(13, 3, 3) = 23093880$ and $F(103, 13, 6) \equiv 878922518\pmod {1\,000\,062\,031}$. Find $F(10^{18} + 31, 10^{14} + 31, 62)$. Give your answer modulo $1\,000\,062\,031$.
<p> Recall the blancmange function from <a href="problem=226">Problem 226</a>: $T(x) = \sum\limits_{n = 0}^\infty\dfrac{s(2^nx)}{2^n}$, where $s(x)$ is the distance from $x$ to the nearest integer.</p> <p> For positive integers $k, t, r$, we write $$F(k, t, r) = (2^{2k} - 1)T\left(\frac{(2^t + 1)^r}{2^k + 1}\right).$$ It can be shown that $F(k, t, r)$ is always an integer.<br> For example, $F(3, 1, 1) = 42$, $F(13, 3, 3) = 23093880$ and $F(103, 13, 6) \equiv 878922518\pmod {1\,000\,062\,031}$.</p> <p> Find $F(10^{18} + 31, 10^{14} + 31, 62)$. Give your answer modulo $1\,000\,062\,031$.</p>
https://projecteuler.net/problem=889
424315113
890
Let $p(n)$ be the number of ways to write $n$ as the sum of powers of two, ignoring order. For example, $p(7) = 6$, the partitions being $$ \begin{align} 7 &= 1+1+1+1+1+1+1 \\ &=1+1+1+1+1+2 \\ &=1+1+1+2+2 \\ &=1+1+1+4 \\ &=1+2+2+2 \\ &=1+2+4 \end{align} $$ You are also given $p(7^7) \equiv 144548435 \pmod {10^9+7}$. Find $p(7^{777})$. Give your answer modulo $10^9 + 7$.
<p>Let $p(n)$ be the number of ways to write $n$ as the sum of powers of two, ignoring order.</p> <p>For example, $p(7) = 6$, the partitions being $$ \begin{align} 7 &amp;= 1+1+1+1+1+1+1 \\ &amp;=1+1+1+1+1+2 \\ &amp;=1+1+1+2+2 \\ &amp;=1+1+1+4 \\ &amp;=1+2+2+2 \\ &amp;=1+2+4 \end{align} $$ You are also given $p(7^7) \equiv 144548435 \pmod {10^9+7}$.</p> <p>Find $p(7^{777})$. Give your answer modulo $10^9 + 7$.</p>
https://projecteuler.net/problem=890
820442179
891
A round clock only has three hands: hour, minute, second. All hands look identical and move continuously. Moreover, there is no number or reference mark so that the "upright position" is unknown. The clock functions the same as a normal 12-hour analogue clock. Despite the inconvenient design, for most time it is possible to tell the correct time (within a 12-hour cycle) from the clock, just by measuring accurately the angles between the hands. For example, if all three hands coincide, then the time must be 12:00:00. Nevertheless, there are several moments where the clock shows an ambiguous reading. For example, the following moment could be either 1:30:00 or 7:30:00 (with the clock rotated $180^\circ$). Thus both 1:30:00 and 7:30:00 are ambiguous moments. Note that even if two hands perfectly coincide, we can still see them as two distinct hands in the same position. Thus for example 3:00:00 and 9:00:00 are not ambiguous moments. How many ambiguous moments are there within a 12-hour cycle?
<p> A round clock only has three hands: hour, minute, second. All hands look identical and move continuously. Moreover, there is no number or reference mark so that the "upright position" is unknown. The clock functions the same as a normal 12-hour analogue clock.</p> <p> Despite the inconvenient design, for most time it is possible to tell the correct time (within a 12-hour cycle) from the clock, just by measuring accurately the angles between the hands. For example, if all three hands coincide, then the time must be 12:00:00.</p> <p> Nevertheless, there are several moments where the clock shows an ambiguous reading. For example, the following moment could be either 1:30:00 or 7:30:00 (with the clock rotated $180^\circ$). Thus both 1:30:00 and 7:30:00 are ambiguous moments.<br> Note that even if two hands perfectly coincide, we can still see them as two distinct hands in the same position. Thus for example 3:00:00 and 9:00:00 are not ambiguous moments. </p> <div style="text-align:center;"><img src="resources/images/0891_clock.png?1714250610" alt="0891_clock.png"></div> <p> How many ambiguous moments are there within a 12-hour cycle?</p>
https://projecteuler.net/problem=891
1541414
892
Consider a circle where $2n$ distinct points have been marked on its circumference. A cutting $C$ consists of connecting the $2n$ points with $n$ line segments, so that no two line segments intersect, including on their end points. The $n$ line segments then cut the circle into $n + 1$ pieces. Each piece is painted either black or white, so that adjacent pieces are opposite colours. Let $d(C)$ be the absolute difference between the numbers of black and white pieces under the cutting $C$. Let $D(n)$ be the sum of $d(C)$ over all different cuttings $C$. For example, there are five different cuttings with $n = 3$. The upper three cuttings all have $d = 0$ because there are two black and two white pieces; the lower two cuttings both have $d = 2$ because there are three black and one white pieces. Therefore $D(3) = 0 + 0 + 0 + 2 + 2 = 4$. You are also given $D(100) \equiv 1172122931\pmod{1234567891}$. Find $\displaystyle \sum_{n=1}^{10^7} D(n)$. Give your answer modulo $1234567891$.
<p> Consider a circle where $2n$ distinct points have been marked on its circumference.</p> <p> A <i>cutting</i> $C$ consists of connecting the $2n$ points with $n$ line segments, so that no two line segments intersect, including on their end points. The $n$ line segments then cut the circle into $n + 1$ pieces. Each piece is painted either black or white, so that adjacent pieces are opposite colours. Let $d(C)$ be the absolute difference between the numbers of black and white pieces under the cutting $C$.</p> <p> Let $D(n)$ be the sum of $d(C)$ over all different cuttings $C$. For example, there are five different cuttings with $n = 3$.</p> <div style="text-align:center;"> <img src="resources/images/0892_Zebra.png?1714876283" alt="0892_Zebra.png"></div> <p> The upper three cuttings all have $d = 0$ because there are two black and two white pieces; the lower two cuttings both have $d = 2$ because there are three black and one white pieces. Therefore $D(3) = 0 + 0 + 0 + 2 + 2 = 4$. You are also given $D(100) \equiv 1172122931\pmod{1234567891}$.</p> <p> Find $\displaystyle \sum_{n=1}^{10^7} D(n)$. Give your answer modulo $1234567891$.</p>
https://projecteuler.net/problem=892
469137427
893
Define $M(n)$ to be the minimum number of matchsticks needed to represent the number $n$. A number can be represented in digit form or as an expression involving addition and/or multiplication. Also order of operations must be followed, that is multiplication binding tighter than addition. Any other symbols or operations, such as brackets, subtraction, division or exponentiation, are not allowed. The valid digits and symbols are shown below: For example, $28$ needs $12$ matchsticks to represent it in digit form but representing it as $4\times 7$ would only need $9$ matchsticks and as there is no way using fewer matchsticks $M(28) = 9$. Define $\displaystyle T(N) = \sum_{n=1}^N M(n)$. You are given $T(100) = 916$. Find $T(10^6)$.
<p> Define $M(n)$ to be the minimum number of matchsticks needed to represent the number $n$.</p> <p> A number can be represented in digit form or as an expression involving addition and/or multiplication. Also order of operations must be followed, that is multiplication binding tighter than addition. Any other symbols or operations, such as brackets, subtraction, division or exponentiation, are not allowed.</p> <p> The valid digits and symbols are shown below:</p> <div style="text-align:center;"> <img src="resources/images/0893_DigitDiagram.jpg?1714876316" alt="0893_DigitDiagram.jpg" height="433" width="668"></div> <p> For example, $28$ needs $12$ matchsticks to represent it in digit form but representing it as $4\times 7$ would only need $9$ matchsticks and as there is no way using fewer matchsticks $M(28) = 9$.</p> <p> Define $\displaystyle T(N) = \sum_{n=1}^N M(n)$. You are given $T(100) = 916$.</p> <p> Find $T(10^6)$.</p>
https://projecteuler.net/problem=893
26688208
894
Consider a unit circlecircle with radius 1 $C_0$ on the plane that does not enclose the origin. For $k\ge 1$, a circle $C_k$ is created by scaling and rotating $C_{k - 1}$ with respect to the origin. That is, both the radius and the distance to the origin are scaled by the same factor, and the centre of rotation is the origin. The scaling factor is positive and strictly less than one. Both it and the rotation angle remain constant for each $k$. It is given that $C_0$ is externally tangent to $C_1$, $C_7$ and $C_8$, as shown in the diagram below, and no two circles overlap. Find the total area of all the circular trianglesA circular triangle is a triangle with circular arc edges in the diagram, i.e. the area painted green above. Give your answer rounded to $10$ places after the decimal point.
<p>Consider a <strong class="tooltip">unit circle<span class="tooltiptext">circle with radius 1</span></strong> $C_0$ on the plane that does not enclose the origin. For $k\ge 1$, a circle $C_k$ is created by scaling and rotating $C_{k - 1}$ <b>with respect to the origin</b>. That is, both the radius and the distance to the origin are scaled by the same factor, and the centre of rotation is the origin. The scaling factor is positive and strictly less than one. Both it and the rotation angle remain constant for each $k$.</p> <p>It is given that $C_0$ is externally tangent to $C_1$, $C_7$ and $C_8$, as shown in the diagram below, and no two circles overlap.</p> <div style="text-align:center;"><img src="resources/images/0894_circle_spiral.jpg?1714305246" alt="0894_circle_spiral.jpg"></div> <p>Find the total area of all the <strong class="tooltip">circular triangles<span class="tooltiptext">A circular triangle is a triangle with circular arc edges</span></strong> in the diagram, i.e. the area painted green above.<br> Give your answer rounded to $10$ places after the decimal point.</p>
https://projecteuler.net/problem=894
0.7718678168
895
Gary and Sally play a game using gold and silver coins arranged into a number of vertical stacks, alternating turns. On Gary's turn he chooses a gold coin and removes it from the game along with any other coins sitting on top. Sally does the same on her turn by removing a silver coin. The first player unable to make a move loses. An arrangement is called fair if the person moving first, whether it be Gary or Sally, will lose the game if both play optimally. An arrangement is called balanced if the number of gold and silver coins are equal. Define $G(m)$ to be the number of fair and balanced arrangements consisting of three non-empty stacks, each not exceeding $m$ in size. Different orderings of the stacks are to be counted separately, so $G(2)=6$ due to the following six arrangements: You are also given $G(5)=348$ and $G(20)=125825982708$. Find $G(9898)$ giving your answer modulo $989898989$.
<p> Gary and Sally play a game using gold and silver coins arranged into a number of vertical stacks, alternating turns. On Gary's turn he chooses a gold coin and removes it from the game along with any other coins sitting on top. Sally does the same on her turn by removing a silver coin. The first player unable to make a move loses.</p> <p> An arrangement is called <dfn>fair</dfn> if the person moving first, whether it be Gary or Sally, will lose the game if both play optimally.</p> <p> An arrangement is called <dfn>balanced</dfn> if the number of gold and silver coins are equal.</p> <p> Define $G(m)$ to be the number of fair and balanced arrangements consisting of three non-empty stacks, each not exceeding $m$ in size. Different orderings of the stacks are to be counted separately, so $G(2)=6$ due to the following six arrangements:</p> <div style="text-align:center;"><img src="resources/images/0895_G2.png?1714251811" alt="0895_G2.png"></div> <p> You are also given $G(5)=348$ and $G(20)=125825982708$.</p> <p> Find $G(9898)$ giving your answer modulo $989898989$.</p>
https://projecteuler.net/problem=895
670785433
896
A contiguous range of positive integers is called a divisible range if all the integers in the range can be arranged in a row such that the $n$-th term is a multiple of $n$. For example, the range $[6..9]$ is a divisible range because we can arrange the numbers as $7,6,9,8$. In fact, it is the $4$th divisible range of length $4$, the first three being $[1..4], [2..5], [3..6]$. Find the $36$th divisible range of length $36$. Give as answer the smallest number in the range.
<p> A contiguous range of positive integers is called a <dfn>divisible range</dfn> if all the integers in the range can be arranged in a row such that the $n$-th term is a multiple of $n$.<br> For example, the range $[6..9]$ is a divisible range because we can arrange the numbers as $7,6,9,8$.<br> In fact, it is the $4$th divisible range of length $4$, the first three being $[1..4], [2..5], [3..6]$.</p> <p> Find the $36$th divisible range of length $36$.<br> Give as answer the smallest number in the range.</p>
https://projecteuler.net/problem=896
274229635640
897
Let $G(n)$ denote the largest possible area of an $n$-gona polygon with $n$ sides contained in the region $\{(x, y) \in \Bbb R^2: x^4 \leq y \leq 1\}$. For example, $G(3) = 1$ and $G(5)\approx 1.477309771$. Find $G(101)$ rounded to nine digits after the decimal point.
<p> Let $G(n)$ denote the largest possible area of an <strong class="tooltip">$n$-gon<span class="tooltiptext">a polygon with $n$ sides</span></strong> contained in the region $\{(x, y) \in \Bbb R^2: x^4 \leq y \leq 1\}$.<br> For example, $G(3) = 1$ and $G(5)\approx 1.477309771$.<br> Find $G(101)$ rounded to nine digits after the decimal point.</p>
https://projecteuler.net/problem=897
1.599827123
898
Claire Voyant is a teacher playing a game with a class of students. A fair coin is tossed on the table. All the students can see the outcome of the toss, but Claire cannot. Each student then tells Claire whether the outcome is head or tail. The students may lie, but Claire knows the probability that each individual student lies. Moreover, the students lie independently. After that, Claire attempts to guess the outcome using an optimal strategy. For example, for a class of four students with lying probabilities $20\%,40\%,60\%,80\%$, Claire guesses correctly with probability 0.832. Find the probability that Claire guesses correctly for a class of 51 students each lying with a probability of $25\%, 26\%, \dots, 75\%$ respectively. Give your answer rounded to 10 digits after the decimal point.
<p> Claire Voyant is a teacher playing a game with a class of students. A fair coin is tossed on the table. All the students can see the outcome of the toss, but Claire cannot. Each student then tells Claire whether the outcome is head or tail. The students may lie, but Claire knows the probability that each individual student lies. Moreover, the students lie independently. After that, Claire attempts to guess the outcome using an optimal strategy. </p> <p> For example, for a class of four students with lying probabilities $20\%,40\%,60\%,80\%$, Claire guesses correctly with probability 0.832. </p> <p> Find the probability that Claire guesses correctly for a class of 51 students each lying with a probability of $25\%, 26\%, \dots, 75\%$ respectively. </p> <p> Give your answer rounded to 10 digits after the decimal point. </p>
https://projecteuler.net/problem=898
0.9861343531
899
Two players play a game with two piles of stones. The players alternately take stones from one or both piles, subject to: - the total number of stones taken is equal to the size of the smallest pile before the move; - the move cannot take all the stones from a pile. The player that is unable to move loses. For example, if the piles are of sizes 3 and 5 then there are three possible moves. $$(3,5) \xrightarrow{(2,1)} (1,4)\qquad\qquad (3,5) \xrightarrow{(1,2)} (2,3)\qquad\qquad (3,5) \xrightarrow{(0,3)} (3,2)$$ Let $L(n)$ be the number of ordered pairs $(a,b)$ with $1 \leq a,b \leq n$ such that the initial game position with piles of sizes $a$ and $b$ is losing for the first player assuming optimal play. You are given $L(7) = 21$ and $L(7^2) = 221$. Find $L(7^{17})$.
<p> Two players play a game with two piles of stones. The players alternately take stones from one or both piles, subject to:</p> <ol> <li>the total number of stones taken is equal to the size of the smallest pile before the move;</li> <li>the move cannot take all the stones from a pile.</li> </ol> <p> The player that is unable to move loses.</p> <p> For example, if the piles are of sizes 3 and 5 then there are three possible moves. $$(3,5) \xrightarrow{(2,1)} (1,4)\qquad\qquad (3,5) \xrightarrow{(1,2)} (2,3)\qquad\qquad (3,5) \xrightarrow{(0,3)} (3,2)$$</p> <p> Let $L(n)$ be the number of ordered pairs $(a,b)$ with $1 \leq a,b \leq n$ such that the initial game position with piles of sizes $a$ and $b$ is losing for the first player assuming optimal play.</p> <p> You are given $L(7) = 21$ and $L(7^2) = 221$.</p> <p> Find $L(7^{17})$.</p>
https://projecteuler.net/problem=899
10784223938983273
900
Two players play a game with at least two piles of stones. The players alternately take stones from one or more piles, subject to: - the total number of stones taken is equal to the size of the smallest pile before the move; - the move cannot take all the stones from a pile. The player that is unable to move loses. For example, if the piles are of sizes 2, 2 and 4 then there are four possible moves. $$ (2,2,4)\xrightarrow{(1,1,0)}(1,1,4)\quad (2,2,4)\xrightarrow{(1,0,1)}(1,2,3)\quad (2,2,4)\xrightarrow{(0,1,1)}(2,1,3)\quad (2,2,4)\xrightarrow{(0,0,2)}(2,2,2)$$ Let $t(n)$ be the smallest nonnegative integer $k$ such that the position with $n$ piles of $n$ stones and a single pile of $n+k$ stones is losing for the first player assuming optimal play. For example, $t(1) = t(2) = 0$ and $t(3) = 2$. Define $\displaystyle S(N) = \sum_{n=1}^{2^N} t(n)$. You are given $S(10) = 361522$. Find $S(10^4)$. Give your answer modulo $900497239$.
<p> Two players play a game with at least two piles of stones. The players alternately take stones from one or more piles, subject to:</p> <ol> <li>the total number of stones taken is equal to the size of the smallest pile before the move;</li> <li>the move cannot take all the stones from a pile.</li> </ol> <p> The player that is unable to move loses.</p> <p> For example, if the piles are of sizes 2, 2 and 4 then there are four possible moves. $$ (2,2,4)\xrightarrow{(1,1,0)}(1,1,4)\quad (2,2,4)\xrightarrow{(1,0,1)}(1,2,3)\quad (2,2,4)\xrightarrow{(0,1,1)}(2,1,3)\quad (2,2,4)\xrightarrow{(0,0,2)}(2,2,2)$$</p> <p> Let $t(n)$ be the smallest nonnegative integer $k$ such that the position with $n$ piles of $n$ stones and a single pile of $n+k$ stones is losing for the first player assuming optimal play. For example, $t(1) = t(2) = 0$ and $t(3) = 2$.</p> <p> Define $\displaystyle S(N) = \sum_{n=1}^{2^N} t(n)$. You are given $S(10) = 361522$.</p> <p> Find $S(10^4)$. Give your answer modulo $900497239$. </p>
https://projecteuler.net/problem=900
646900900