{"id":"aimepp-hard-0001","problem":"Define $K_N=\\displaystyle\\prod_{j=1}^N(j!)^j$. Write $K_{236}=19^E U$, where $19\\nmid U$. Let $Z$ be the least nonnegative residue of $E+U$ modulo $997$. Define $P(x)=x^{5} - 9 x^{4} + 349 x^{3} - 3 x^{2} + 7 x$ and $Q(x)=x^{4} + 692 x^{2} + 8 x - 63$. Find the least nonnegative residue modulo $1000$ of the resultant $\\operatorname{Res}_x(P,Q)$.","answer":929,"answer_str":"929","tier":"AIME Hard"} {"id":"aimepp-hard-0002","problem":"Let $Z$ be the least nonnegative residue modulo $1000$ of the number of reduced fractions $a/b$ that satisfy $\\frac{1}{5}0$. Find the least nonnegative residue of $p+q$ modulo $1000$.","answer":771,"answer_str":"771","tier":"AIME Hard"} {"id":"aimepp-hard-0007","problem":"Let $\\theta_k=\\frac{2\\pi k}{19}$ for $1\\le k\\le 18$. If $\\displaystyle\\sum_{k=1}^{18}\\left(\\frac1{(8-2\\cos\\theta_k)^2}+\\frac{2}{8-2\\cos\\theta_k}\\right)=\\frac pq$ in lowest terms, let $Z$ be the least nonnegative residue of $p+q$ modulo $1000$. Let $m=8+(Z\\bmod 9)$. Form a wheel with hub $0$ and rim vertices $1,2,\\ldots,m$ in cyclic order. Give spoke $0j$ weight $1+((Z+j^2+9j)\\bmod5)$ and rim edge $j(j+1)$ weight $1+((2Z+4j+j^2)\\bmod5)$, with $m+1$ interpreted as $1$. The weight of a spanning tree is the product of its edge weights. Find the total weight of all spanning trees modulo $1000$.","answer":525,"answer_str":"525","tier":"AIME Hard"} {"id":"aimepp-hard-0008","problem":"Let $Z$ be the least nonnegative residue modulo $1000$ of the number of $5\\times5$ zero-one matrices that have every row sum equal to $2$ or $3$, exactly $1$ rows of sum $3$, no zero column, rank $4$ over $\\mathbb F_2$, trace $3$, an anti-diagonal sum congruent to $0$ modulo $3$, and exactly $5$ columns of odd sum. Find the least nonnegative residue modulo $1000$ of the number of words of length $Z+53$ over $\\{0,1,2\\}$ that contain none of the blocks $012$, $121$, $210$, have digit sum congruent to $3$ modulo $5$, and contain a number of $2$'s congruent to $2$ modulo $4$.","answer":702,"answer_str":"702","tier":"AIME Hard"} {"id":"aimepp-hard-0009","problem":"Define $K_N=\\displaystyle\\prod_{j=1}^N(j!)^j$. Write $K_{195}=11^E U$, where $11\\nmid U$. Let $Z$ be the least nonnegative residue of $E+U$ modulo $997$. Put $L=Z+30$. Define $G(n,0)=1$, $G(0,k)=0$ for $k>0$, and $G(n,k)=G(n-1,k)+7^{n-k}G(n-1,k-1)$. Find the least nonnegative residue modulo $1000$ of $G(L,11)+3G(L,10)$.","answer":208,"answer_str":"208","tier":"AIME Hard"} {"id":"aimepp-hard-0010","problem":"On an $8\\times 8$ board, row $i$ contains exactly the first $b_i$ allowed squares, where $(b_1,\\ldots,b_8)=(1, 2, 3, 7, 8, 8, 8, 8)$. Let $Z$ be the least nonnegative residue modulo $1000$ of the number of ways to place $8$ nonattacking rooks, one in each row and column, so that exactly $4$ rooks lie on the main diagonal, the induced column permutation has inversion parity $1$, and $\\sum_{i=1}^8 i\\pi(i)\\equiv 5\\pmod{8}$. Let $n=7+(Z\\bmod 4)$ and let $M=(m_{ij})_{0\\le i,jy$ and $x^2-xy+y^2=N$, consider those satisfying $2x-y\\equiv 11\\pmod{13}$. Let $Z$ be the least nonnegative residue modulo $1000$ of the sum of $3x+y$ over all such pairs. Define $u_0=81$ and $u_1=458$, and for $k\\ge 0$ define $u_{k+2}$ by $u_{k+2}\\equiv 11u_{k+1}+9u_k+12(-1)^k\\pmod{1000}$, with every $u_k$ chosen from $\\{0,1,\\ldots,999\\}$. Find the least nonnegative residue modulo $1000$ of $u_{Z^2+9Z+87}+13u_{2Z+43}$.","answer":545,"answer_str":"545","tier":"AIME Hard"} {"id":"aimepp-hard-0013","problem":"Let $Y(x)$ be the unique formal power series with constant term $0$ satisfying $Y=x(1+Y)^{2}(1+Y^2)^{3}(1-Y)^{-1}$. Let $Z$ be the least nonnegative residue modulo $991$ of the coefficient of $x^{43}$ in $Y(x)^{10}$. Let $p=2129$, let $A$ and $B$ be the least nonnegative residues modulo $p$ of $611Z+422$ and $1387Z+870$, respectively, and consider $E: y^2=x^3+Ax+B$ over $\\mathbb F_p$. Including the point at infinity, let $C=\\#E(\\mathbb F_p)$, and let $X$ be the sum, as ordinary integers, of the $x$-coordinates of all affine points of $E$. Find the least nonnegative residue of $C+5X$ modulo $1000$.","answer":723,"answer_str":"723","tier":"AIME Hard"} {"id":"aimepp-hard-0014","problem":"Over the ring $(\\mathbb Z/1000\\mathbb Z)[x]$, let $c_0+c_1x+\\cdots+c_6x^6$ be the remainder when $(x^2+x^4+3)^{154655378506}$ is divided by the monic polynomial $P(x)=x^{7} - 5 x^{6} - 6 x^{5} - 5 x^{4} - 2 x^{3} - 5 x - 5$. Let $Z$ be the least nonnegative residue of $9c_0+1c_1+2c_2+7c_3+5c_4+2c_5+9c_6$ modulo $1000$. Set $T=11^{Z+1}+\\displaystyle\\sum_{k=0}^Z(-1)^k\\binom Zk13^k23^{Z-k}(k^3+5k^2+7k+2)$. Find the least nonnegative residue of $T$ modulo $1000$.","answer":611,"answer_str":"611","tier":"AIME Hard"} {"id":"aimepp-hard-0015","problem":"Let $Z$ be the least nonnegative residue modulo $1000$ of the number of reduced fractions $a/b$ that satisfy $\\frac{1}{5}0$. Find the least nonnegative residue of $p+q$ modulo $1000$.","answer":115,"answer_str":"115","tier":"AIME Hard"} {"id":"aimepp-hard-0020","problem":"The sequence $(a_n)$ is defined by $(a_0,a_1,\\ldots,a_5)=(17, 16, -12, -18, 13, 10)$ and $a_{n+6}=8a_{n+5}-2a_{n+4}+7a_{n+3}-6a_{n+2}-5a_{n+1}+8a_n$ for $n\\ge0$. Let $M$ be the $5\\times5$ matrix whose $(i,j)$ entry is $a_{8798202908543+i+j}-5a_{8798202908543+i+j+1}$, where $0\\le i,j\\le4$. Let $Z$ be the least nonnegative residue of $\\det(M)$ modulo $997$. Put $L=Z+58$. Define $G(n,0)=1$, $G(0,k)=0$ for $k>0$, and $G(n,k)=G(n-1,k)+7^{n-k}G(n-1,k-1)$. Find the least nonnegative residue modulo $1000$ of $G(L,9)+5G(L,8)$.","answer":475,"answer_str":"475","tier":"AIME Hard"} {"id":"aimepp-hard-0021","problem":"The sequence $(a_n)$ is defined by $(a_0,a_1,\\ldots,a_5)=(-18, -13, 14, 11, -13, -9)$ and $a_{n+6}=5a_{n+5}+7a_{n+4}+8a_{n+3}-8a_{n+2}+7a_{n+1}+3a_n$ for $n\\ge0$. Let $M$ be the $5\\times5$ matrix whose $(i,j)$ entry is $a_{2431472563692+i+j}-1a_{2431472563692+i+j+1}$, where $0\\le i,j\\le4$. Let $Z$ be the least nonnegative residue of $\\det(M)$ modulo $997$. Put $L=18+(Z\\bmod 13)$ and, for $1\\le j\\le L$, put $a_j=1+((Zj^2+8j+4)\\bmod 11)$. If $[a_1;a_2,\\ldots,a_L]=p_L/q_L$ and $p_{L-1}/q_{L-1}=[a_1;\\ldots,a_{L-1}]$ are in lowest terms, find the least nonnegative residue modulo $1000$ of $p_L+q_L+3p_{L-1}+3q_{L-1}$.","answer":967,"answer_str":"967","tier":"AIME Hard"} {"id":"aimepp-hard-0022","problem":"Let $N=38909$. Among all pairs of positive integers $(x,y)$ satisfying $x0$. Find the least nonnegative residue of $p+q$ modulo $1000$.","answer":149,"answer_str":"149","tier":"AIME Hard"} {"id":"aimepp-hard-0024","problem":"On an $8\\times 8$ board, row $i$ contains exactly the first $b_i$ allowed squares, where $(b_1,\\ldots,b_8)=(2, 3, 6, 8, 8, 8, 8, 8)$. Let $Z$ be the least nonnegative residue modulo $1000$ of the number of ways to place $8$ nonattacking rooks, one in each row and column, so that exactly $0$ rooks lie on the main diagonal, the induced column permutation has inversion parity $1$, and $\\sum_{i=1}^8 i\\pi(i)\\equiv 2\\pmod{5}$. Put $H=Z+107$. Find the least nonnegative residue modulo $1000$ of the number of ordered pairs $(a,b)$ that satisfy $1\\le a0$, and $G(n,k)=G(n-1,k)+7^{n-k}G(n-1,k-1)$. Find the least nonnegative residue modulo $1000$ of $G(L,9)+3G(L,8)$.","answer":413,"answer_str":"413","tier":"AIME Hard"} {"id":"aimepp-hard-0031","problem":"In triangle $ABC$, the side lengths opposite $A,B,C$ are $26,32,12$, respectively. An interior point $P$ has barycentric coordinates $(5:2:2)$, and $Q$ is the isogonal conjugate of $P$. If $PQ^2=p/q$ in lowest terms, let $Z$ be the least nonnegative residue of $p+q$ modulo $1000$. In the quotient ring $(\\mathbb Z/1000\\mathbb Z)[x]/(x^{5}+5x^{4}+3x^{3}+6x^{2}+5x-3)$, write $(-2x^{4}+3x^{3}-4x^{2}-x-2)^{Z^2+10Z+101}=r_0+r_1x+r_2x^2+r_3x^3+r_4x^4$. Find the least nonnegative residue modulo $1000$ of $-3r_0-5r_1-5r_2+9r_3+4r_4$.","answer":9,"answer_str":"009","tier":"AIME Hard"} {"id":"aimepp-hard-0032","problem":"Let $r_1,r_2,r_3,r_4$ be the roots of $P(x)=x^{4} + 7 x^{3} - 3 x^{2} - 3 x + 7$. For $i0$, and $G(n,k)=G(n-1,k)+2^{n-k}G(n-1,k-1)$. Find the least nonnegative residue modulo $1000$ of $G(L,8)+3G(L,7)$.","answer":828,"answer_str":"828","tier":"AIME Hard"} {"id":"aimepp-hard-0034","problem":"Consider ordered pairs $(x,y)$ of least positive residues modulo $1296$ satisfying $xy\\equiv 701\\pmod{1296}$, $x+y\\equiv 8\\pmod{14}$, and $x+2y\\equiv 4\\pmod{5}$. Let $Z$ be the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum(x+3y)$ over all such pairs. Find the least nonnegative residue modulo $1000$ of the number of words of length $Z+60$ over $\\{0,1,2\\}$ that contain none of the blocks $102$, $11$, $201$, have digit sum congruent to $5$ modulo $9$, and contain a number of $2$'s congruent to $1$ modulo $4$.","answer":124,"answer_str":"124","tier":"AIME Hard"} {"id":"aimepp-hard-0035","problem":"Let $N=329509$. For all coprime positive integer pairs $(x,y)$ with $x>y$ and $x^2-xy+y^2=N$, consider those satisfying $2x-y\\equiv 7\\pmod{9}$. Let $Z$ be the least nonnegative residue modulo $1000$ of the sum of $3x+y$ over all such pairs. A Markov chain has transition matrix $\\frac1{10}\\begin{pmatrix}4 & 2 & 2 & 2\\\\2 & 3 & 2 & 3\\\\7 & 1 & 1 & 1\\\\3 & 1 & 3 & 3\\end{pmatrix}$. It starts in state $1$. After $Z+33$ steps, the probability that it is in one of the states $\\{2,4\\}$ is $p/q$ in lowest terms with $q>0$. Find the least nonnegative residue of $p+q$ modulo $1000$.","answer":887,"answer_str":"887","tier":"AIME Hard"} {"id":"aimepp-hard-0036","problem":"Let $C_{315}=\\frac1{316}\\binom{630}{315}$ be a Catalan number. Write $C_{315}=3^e u$ with $3\\nmid u$. Let $Z$ be the least nonnegative residue of $u+81e$ modulo $1000$. Define $u_0=402$ and $u_1=422$, and for $k\\ge 0$ define $u_{k+2}$ by $u_{k+2}\\equiv 19u_{k+1}-17u_k+7(-1)^k\\pmod{1000}$, with every $u_k$ chosen from $\\{0,1,\\ldots,999\\}$. Find the least nonnegative residue modulo $1000$ of $u_{Z^2+11Z+60}+7u_{2Z+12}$.","answer":192,"answer_str":"192","tier":"AIME Hard"} {"id":"aimepp-hard-0037","problem":"Let $p=2017$. A number $g$ with $10$, let $Z$ be the least nonnegative residue of $p+q$ modulo $1000$. Define $P(x)=x^{5} - 4 x^{4} + 457 x^{3} + 6 x^{2} - x - 3$ and $Q(x)=x^{4} + 2 x^{3} + 917 x^{2} + 2 x - 8$. Find the least nonnegative residue modulo $1000$ of the resultant $\\operatorname{Res}_x(P,Q)$.","answer":234,"answer_str":"234","tier":"AIME Hard"} {"id":"aimepp-hard-0056","problem":"For $0\\le i,j\\le5$, define $m_{ij}=\\binom{37+i+j}{20+2i-j}+4\\binom{37+i+j}{20-i+2j}+2\\binom{37+i+j}{20+i-j-2}$, where a binomial coefficient is $0$ when its lower index is outside its usual range. If $M=(m_{ij})_{0\\le i,j\\le5}$, let $Z$ be the least nonnegative residue of $\\det M$ modulo $991$. Write $Z=100d_2+10d_1+d_0$ with $0\\le d_0,d_1,d_2\\le9$. Let $\\lambda=(16+d_2+d_1+d_0,12+d_1+d_0,8+d_0,4,2)$. Find the least nonnegative residue modulo $1000$ of the number of standard Young tableaux of shape $\\lambda$.","answer":0,"answer_str":"000","tier":"AIME Hard"} {"id":"aimepp-hard-0057","problem":"Let $p=1579$. A number $g$ with $1a_i$ congruent to $1$ modulo $3$. Let $m=8+(Z\\bmod 9)$. Form a wheel with hub $0$ and rim vertices $1,2,\\ldots,m$ in cyclic order. Give spoke $0j$ weight $1+((Z+j^2+j)\\bmod5)$ and rim edge $j(j+1)$ weight $1+((2Z+7j+j^2)\\bmod5)$, with $m+1$ interpreted as $1$. The weight of a spanning tree is the product of its edge weights. Find the total weight of all spanning trees modulo $1000$.","answer":133,"answer_str":"133","tier":"AIME Hard"} {"id":"aimepp-hard-0060","problem":"Consider ordered pairs $(x,y)$ of least positive residues modulo $12960$ satisfying $xy\\equiv 5729\\pmod{12960}$, $x+y\\equiv 6\\pmod{8}$, and $x+2y\\equiv 2\\pmod{9}$. Let $Z$ be the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum(x+3y)$ over all such pairs. Put $L=18+(Z\\bmod 13)$ and, for $1\\le j\\le L$, put $a_j=1+((Zj^2+4j+9)\\bmod 11)$. If $[a_1;a_2,\\ldots,a_L]=p_L/q_L$ and $p_{L-1}/q_{L-1}=[a_1;\\ldots,a_{L-1}]$ are in lowest terms, find the least nonnegative residue modulo $1000$ of $p_L+q_L+3p_{L-1}+11q_{L-1}$.","answer":534,"answer_str":"534","tier":"AIME Hard"} {"id":"aimepp-hard-0061","problem":"The sequence $(a_n)$ is defined by $(a_0,a_1,\\ldots,a_5)=(16, -18, 18, -17, -16, 16)$ and $a_{n+6}=-8a_{n+5}+4a_{n+2}-7a_{n+1}-a_n$ for $n\\ge0$. Let $M$ be the $5\\times5$ matrix whose $(i,j)$ entry is $a_{917841055891+i+j}-4a_{917841055891+i+j+1}$, where $0\\le i,j\\le4$. Let $Z$ be the least nonnegative residue of $\\det(M)$ modulo $997$. Put $L=Z+39$. For an integer $q\\ge2$, let $P_q(L)$ be the number of rotation classes of aperiodic length-$L$ words over a $q$-letter alphabet. Find the least nonnegative residue modulo $1000$ of $P_6(L)+3P_5(L)+\\varphi(L)$, where here $q=6$.","answer":910,"answer_str":"910","tier":"AIME Hard"} {"id":"aimepp-hard-0062","problem":"Let $N=1440$. Consider nondecreasing $4$-tuples of integers $2\\le a_1\\le\\cdots\\le a_4$ whose product is $N$. Among those having exactly $2$ even entries, greatest common divisor $1$, and $a_1+\\cdots+a_4\\equiv 7\\pmod{9}$, let $Z$ be the least nonnegative residue modulo $1000$ of the sum of all possible values of $a_4$. In the quotient ring $(\\mathbb Z/1000\\mathbb Z)[x]/(x^{5}+5x^{4}-2x^{3}-6x^{2}-4x+4)$, write $(x^{3}+3x^{2}+x+5)^{Z^2+8Z+63}=r_0+r_1x+r_2x^2+r_3x^3+r_4x^4$. Find the least nonnegative residue modulo $1000$ of $4r_0+2r_1-7r_2-5r_3-3r_4$.","answer":228,"answer_str":"228","tier":"AIME Hard"} {"id":"aimepp-hard-0063","problem":"Let $C_{243}=\\frac1{244}\\binom{486}{243}$ be a Catalan number. Write $C_{243}=11^e u$ with $11\\nmid u$. Let $Z$ be the least nonnegative residue of $u+67e$ modulo $1000$. Let $M=3080$ and let $R$ be the least nonnegative residue modulo $M$ of $(10Z+239)^2+1(10Z+239)$. Let $\\mathcal S$ be the set of residues $z\\in\\{0,1,\\ldots,M-1\\}$ satisfying $z^2+1z\\equiv R\\pmod M$, $z\\equiv 4\\pmod{12}$, and $s_7(z)\\equiv 4\\pmod{6}$, where $s_7$ is the base-7 digit sum. Find the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum_{z\\in\\mathcal S}((z+1)^2+3z)$.","answer":236,"answer_str":"236","tier":"AIME Hard"} {"id":"aimepp-hard-0064","problem":"Let $p=4597$. A number $g$ with $10$, let $Z$ be the least nonnegative residue of $p_0+q_0$ modulo $1000$. Define $u_0=71$ and $u_1=384$, and for $k\\ge 0$ define $u_{k+2}$ by $u_{k+2}\\equiv 13u_{k+1}-7u_k-13(-1)^k\\pmod{1000}$, with every $u_k$ chosen from $\\{0,1,\\ldots,999\\}$. Find the least nonnegative residue modulo $1000$ of $u_{Z^2+8Z+21}+13u_{2Z+21}$.","answer":590,"answer_str":"590","tier":"AIME Hard"} {"id":"aimepp-hard-0066","problem":"For a positive integer $t$, let $J_2(t)=t^2\\prod_{p\\mid t}(1-p^{-2})$. Let $N=26583700$. Let $Z$ be the least nonnegative residue modulo $997$ of $\\displaystyle\\sum (d+1)J_2(N/d)$, where the sum is over squarefree divisors $d$ of $N$ such that $d\\equiv 0\\pmod{10}$ and $\\Omega(d)\\equiv 1\\pmod2$. Write $Z=100d_2+10d_1+d_0$ with $0\\le d_0,d_1,d_2\\le9$. Let $\\lambda=(17+d_2+d_1+d_0,13+d_1+d_0,9+d_0,4,2)$. Find the least nonnegative residue modulo $1000$ of the number of standard Young tableaux of shape $\\lambda$.","answer":320,"answer_str":"320","tier":"AIME Hard"} {"id":"aimepp-hard-0067","problem":"Let $C_{684}=\\frac1{685}\\binom{1368}{684}$ be a Catalan number. Write $C_{684}=7^e u$ with $7\\nmid u$. Let $Z$ be the least nonnegative residue of $u+70e$ modulo $1000$. Let $p=1657$, set $x_0=Z$, and for $k\\ge0$ let $x_{k+1}$ be the least nonnegative residue modulo $p$ of $x_k^2+939x_k+445$. Find the least nonnegative residue modulo $1000$ of $x_{10^{12}+8Z+50}+3\\displaystyle\\sum_{j=0}^{Z+50}x_j$.","answer":555,"answer_str":"555","tier":"AIME Hard"} {"id":"aimepp-hard-0068","problem":"Two walkers move simultaneously on the lattice, each taking one unit north or east step per second. The lower walker goes from $(0,0)$ to $(9,12)$, and the upper walker goes from $(0,2)$ to $(9,14)$. After every equal number of steps, their current vertices must be distinct. A turn is a change of direction by either walker. Let $Z$ be the least nonnegative residue modulo $1000$ of the number of ordered pairs of walks of such paths that have exactly $24$ turns in total and have the lower path visit exactly $3$ vertices on the line $y=x$, counting its initial vertex. Put $L=Z+62$. Let $S(n,k)$ be a Stirling number of the second kind, and let $A(n,j)$ be the number of permutations of $\\{1,\\ldots,n\\}$ with exactly $j$ descents. Find the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum_{j=0}^{7}(j+1)S(L+j,8)A(L,j)5^j$.","answer":920,"answer_str":"920","tier":"AIME Hard"} {"id":"aimepp-hard-0069","problem":"Let $p=2393$. A number $g$ with $10$, and $G(n,k)=G(n-1,k)+5^{n-k}G(n-1,k-1)$. Find the least nonnegative residue modulo $1000$ of $G(L,7)+2G(L,6)$.","answer":793,"answer_str":"793","tier":"AIME Hard"} {"id":"aimepp-hard-0077","problem":"Let $N=15211$. Consider triples of positive integers $x\\le y\\le z$ satisfying $x^2+y^2+z^2=N$ and $\\gcd(x,y,z)=1$. Among those with $x+y+z\\equiv 5\\pmod{8}$, let $Z$ be the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum(x+2y+3z)$. Set $T=7^{Z+1}+\\displaystyle\\sum_{k=0}^Z(-1)^k\\binom Zk7^k5^{Z-k}(k^3+7k^2-8k-17)$. Find the least nonnegative residue of $T$ modulo $1000$.","answer":711,"answer_str":"711","tier":"AIME Hard"} {"id":"aimepp-hard-0078","problem":"A polynomial $F$ of degree at most $9$ has remainder $1958 + 9901(x-2) + 22240(x-2)^{2} + 28856(x-2)^{3}$ upon division by $(x-2)^4$, remainder $-4622 + 21037(x+2) - 42336(x+2)^{2}$ upon division by $(x+2)^3$, and remainder $-2365048 + 5287741(x+4) - 5245496(x+4)^{2}$ upon division by $(x+4)^3$. Let $Z$ be the least nonnegative residue of $F(-7)$ modulo $1000$. Let $L=Z+31$ and $P=\\displaystyle\\prod_{j=1}^L(4j+4)$. Write $P=5^eU$ with $5\\nmid U$, and let $u$ be the least nonnegative residue of $U$ modulo $5^4=625$. Find the least nonnegative residue modulo $1000$ of $u+13e+2(e\\bmod 4)^2$.","answer":398,"answer_str":"398","tier":"AIME Hard"} {"id":"aimepp-hard-0079","problem":"Let $a_n$ be defined by $\\displaystyle\\sum_{n\\ge0}a_nx^n=\\frac{(1+x^3)^{3}(1+x^7+x^{14})^{2}}{(1-x^5)^{2}(1-x^4)^{4}}$. Let $Z$ be the least nonnegative residue modulo $997$ of $\\displaystyle\\sum_{\\substack{0\\le n\\le 116\\n\\equiv 4\\pmod{9}}}a_n$. Put $L=Z+74$. For an integer $q\\ge2$, let $P_q(L)$ be the number of rotation classes of aperiodic length-$L$ words over a $q$-letter alphabet. Find the least nonnegative residue modulo $1000$ of $P_8(L)+2P_7(L)+\\varphi(L)$, where here $q=8$.","answer":904,"answer_str":"904","tier":"AIME Hard"} {"id":"aimepp-hard-0080","problem":"For a positive integer $t$, let $J_2(t)=t^2\\prod_{p\\mid t}(1-p^{-2})$. Let $N=50611275$. Let $Z$ be the least nonnegative residue modulo $997$ of $\\displaystyle\\sum (d+1)J_2(N/d)$, where the sum is over squarefree divisors $d$ of $N$ such that $d\\equiv 4\\pmod{7}$ and $\\Omega(d)\\equiv 1\\pmod2$. Define $u_0=473$ and $u_1=160$, and for $k\\ge 0$ define $u_{k+2}$ by $u_{k+2}\\equiv 11u_{k+1}+5u_k+7(-1)^k\\pmod{1000}$, with every $u_k$ chosen from $\\{0,1,\\ldots,999\\}$. Find the least nonnegative residue modulo $1000$ of $u_{Z^2+9Z+82}+7u_{2Z+34}$.","answer":636,"answer_str":"636","tier":"AIME Hard"} {"id":"aimepp-hard-0081","problem":"Two walkers move simultaneously on the lattice, each taking one unit north or east step per second. The lower walker goes from $(0,0)$ to $(8,7)$, and the upper walker goes from $(0,2)$ to $(8,9)$. After every equal number of steps, their current vertices must be distinct. A turn is a change of direction by either walker. Let $Z$ be the least nonnegative residue modulo $1000$ of the number of ordered pairs of walks of such paths that have exactly $10$ turns in total and have the lower path visit exactly $5$ vertices on the line $y=x$, counting its initial vertex. Let $A=\\begin{pmatrix}4 & 0 & 1 & 3\\\\2 & 4 & 4 & 3\\\\0 & 3 & 3 & 1\\\\1 & 2 & 4 & 4\\end{pmatrix}$. Interpreting powers over the integers and reducing only the final result, find the least nonnegative residue modulo $1000$ of $\\operatorname{tr}(A^{Z+17})+2(A^{Z^2+70})_{1,4}$.","answer":130,"answer_str":"130","tier":"AIME Hard"} {"id":"aimepp-hard-0082","problem":"The eight vertices of a cube are colored red, green, or blue, using the colors exactly $3, 2, 3$ times, respectively. Two colorings are considered the same when a rotation of the cube carries one to the other. Let $Z$ be the least nonnegative residue modulo $1000$ of the number of equivalence classes that have exactly $5$ edges whose endpoints have the same color. Put $L=Z+23$. Let $S(n,k)$ be a Stirling number of the second kind, and let $A(n,j)$ be the number of permutations of $\\{1,\\ldots,n\\}$ with exactly $j$ descents. Find the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum_{j=0}^{7}(j+1)S(L+j,8)A(L,j)7^j$.","answer":406,"answer_str":"406","tier":"AIME Hard"} {"id":"aimepp-hard-0083","problem":"The eight vertices of a cube are colored red, green, or blue, using the colors exactly $4, 3, 1$ times, respectively. Two colorings are considered the same when a rotation of the cube carries one to the other. Let $Z$ be the least nonnegative residue modulo $1000$ of the number of equivalence classes that have exactly $3$ edges whose endpoints have the same color. Let $R$ be the least nonnegative residue modulo $10^{10}-1$ of $19^{Z^2+5Z+52}+29^{Z+52}+3143072797$, and write $R$ as a block of exactly ten decimal digits, allowing leading zeros. For $0\\le j<10$, let $R_j$ be the integer obtained by cyclically shifting this block left by $j$ places. Find the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum (j+1)\\gcd(R_j,10^{10}-1)$, where the sum is over the integers $j$ with $0\\le j<10$ and $R_j\\equiv 2\\pmod{13}$.","answer":75,"answer_str":"075","tier":"AIME Hard"} {"id":"aimepp-hard-0084","problem":"Let $\\theta_k=\\frac{2\\pi k}{23}$ for $1\\le k\\le 22$. If $\\displaystyle\\sum_{k=1}^{22}\\left(\\frac1{(3-2\\cos\\theta_k)^2}+\\frac{5}{3-2\\cos\\theta_k}\\right)=\\frac pq$ in lowest terms, let $Z$ be the least nonnegative residue of $p+q$ modulo $1000$. In the quotient ring $(\\mathbb Z/1000\\mathbb Z)[x]/(x^{5}+6x^{4}-6x^{3}-3x^{2}+3x+2)$, write $(-5x^{4}-2x^{3}-3x^{2}+2x-2)^{Z^2+6Z+118}=r_0+r_1x+r_2x^2+r_3x^3+r_4x^4$. Find the least nonnegative residue modulo $1000$ of $-3r_0+4r_1+6r_2+9r_3+2r_4$.","answer":814,"answer_str":"814","tier":"AIME Hard"} {"id":"aimepp-hard-0085","problem":"The sequence $(a_n)$ is defined by $(a_0,a_1,\\ldots,a_5)=(-10, -15, -7, -7, -6, -10)$ and $a_{n+6}=6a_{n+5}-3a_{n+4}-6a_{n+2}-6a_n$ for $n\\ge0$. Let $M$ be the $5\\times5$ matrix whose $(i,j)$ entry is $a_{1024512110523+i+j}-2a_{1024512110523+i+j+1}$, where $0\\le i,j\\le4$. Let $Z$ be the least nonnegative residue of $\\det(M)$ modulo $997$. Put $H=Z+105$. Find the least nonnegative residue modulo $1000$ of the number of ordered pairs $(a,b)$ that satisfy $1\\le a0$, let $Z$ be the least nonnegative residue of $p_0+q_0$ modulo $1000$. A Markov chain has transition matrix $\\frac1{12}\\begin{pmatrix}1 & 9 & 1 & 1\\\\5 & 2 & 4 & 1\\\\2 & 2 & 3 & 5\\\\3 & 6 & 1 & 2\\end{pmatrix}$. It starts in state $4$. After $Z+88$ steps, the probability that it is in one of the states $\\{3,4\\}$ is $p/q$ in lowest terms with $q>0$. Find the least nonnegative residue of $p+q$ modulo $1000$.","answer":385,"answer_str":"385","tier":"AIME Hard"} {"id":"aimepp-hard-0089","problem":"A circular ladder has two disjoint $8$-cycles, with corresponding vertices joined by $8$ rungs. Let $Z$ be the least nonnegative residue modulo $1000$ of the number of matchings that contain exactly $8$ edges, exactly $4$ rungs, and a number of edges from the first cycle congruent to $2$ modulo $3$. Put $L=18+(Z\\bmod 13)$ and, for $1\\le j\\le L$, put $a_j=1+((Zj^2+2j+10)\\bmod 15)$. If $[a_1;a_2,\\ldots,a_L]=p_L/q_L$ and $p_{L-1}/q_{L-1}=[a_1;\\ldots,a_{L-1}]$ are in lowest terms, find the least nonnegative residue modulo $1000$ of $p_L+q_L+5p_{L-1}+3q_{L-1}$.","answer":763,"answer_str":"763","tier":"AIME Hard"} {"id":"aimepp-hard-0090","problem":"For $1\\le k<5400$ with $\\gcd(k,5400)=1$ and $k\\equiv 6\\pmod{7}$, define $w_k=\\gcd(k^2+7k+14,5400)\\gcd(k^3+5,5400)$. Let $Z$ be the least nonnegative residue of $\\sum w_k$ modulo $1000$. Let $p=1489$, set $x_0=Z$, and for $k\\ge0$ let $x_{k+1}$ be the least nonnegative residue modulo $p$ of $x_k^2+1400x_k+597$. Find the least nonnegative residue modulo $1000$ of $x_{10^{12}+9Z+78}+7\\displaystyle\\sum_{j=0}^{Z+35}x_j$.","answer":545,"answer_str":"545","tier":"AIME Hard"} {"id":"aimepp-hard-0091","problem":"Let $N=378000$. Consider nondecreasing $4$-tuples of integers $2\\le a_1\\le\\cdots\\le a_4$ whose product is $N$. Among those having exactly $2$ even entries, greatest common divisor $1$, and $a_1+\\cdots+a_4\\equiv 4\\pmod{12}$, let $Z$ be the least nonnegative residue modulo $1000$ of the sum of all possible values of $a_4$. A Markov chain has transition matrix $\\frac1{12}\\begin{pmatrix}1 & 1 & 7 & 3\\\\1 & 3 & 5 & 3\\\\3 & 2 & 6 & 1\\\\2 & 6 & 3 & 1\\end{pmatrix}$. It starts in state $4$. After $Z+88$ steps, the probability that it is in one of the states $\\{1,4\\}$ is $p/q$ in lowest terms with $q>0$. Find the least nonnegative residue of $p+q$ modulo $1000$.","answer":511,"answer_str":"511","tier":"AIME Hard"} {"id":"aimepp-hard-0092","problem":"Let $F(x)=P(x^2+2x+2)$, where $P(x)=x^{4} + 4 x^{3} - 4 x^{2} + x + 3$. The discriminant of $F$ is an integer $D$. Let $Z$ be the least nonnegative residue of $D$ modulo $983$. Put $L=Z+57$. Let $S(n,k)$ be a Stirling number of the second kind, and let $A(n,j)$ be the number of permutations of $\\{1,\\ldots,n\\}$ with exactly $j$ descents. Find the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum_{j=0}^{6}(j+1)S(L+j,7)A(L,j)3^j$.","answer":640,"answer_str":"640","tier":"AIME Hard"} {"id":"aimepp-hard-0093","problem":"A sphere $\\Sigma$ is orthogonal to four spheres having, respectively, center $(6,4,2)$ and squared radius $\\frac{213}{2}$; center $(1,0,2)$ and squared radius $\\frac{71}{2}$; center $(5,7,-6)$ and squared radius $\\frac{239}{2}$; and center $(-3,-8,-6)$ and squared radius $\\frac{87}{2}$. If the center of $\\Sigma$ is $(h,k,\\ell)$ and its squared radius is $\\rho$, and $h^2+k^2+\\ell^2+\\rho=p/q$ in lowest terms, let $Z$ be the least nonnegative residue of $p+q$ modulo $1000$. Define $u_0=445$ and $u_1=369$, and for $k\\ge 0$ define $u_{k+2}$ by $u_{k+2}\\equiv 19u_{k+1}+5u_k-19(-1)^k\\pmod{1000}$, with every $u_k$ chosen from $\\{0,1,\\ldots,999\\}$. Find the least nonnegative residue modulo $1000$ of $u_{Z^2+5Z+33}+13u_{2Z+34}$.","answer":588,"answer_str":"588","tier":"AIME Hard"} {"id":"aimepp-hard-0094","problem":"Let $F(x)=P(x^2+3x+0)$, where $P(x)=x^{4} - 4 x^{3} - 2 x^{2} + 4 x - 1$. The discriminant of $F$ is an integer $D$. Let $Z$ be the least nonnegative residue of $D$ modulo $991$. Let $R$ be the least nonnegative residue modulo $10^{10}-1$ of $17^{Z^2+7Z+99}+41^{Z+99}+6210865758$, and write $R$ as a block of exactly ten decimal digits, allowing leading zeros. For $0\\le j<10$, let $R_j$ be the integer obtained by cyclically shifting this block left by $j$ places. Find the least nonnegative residue modulo $1000$ of $\\displaystyle\\sum (j+1)\\gcd(R_j,10^{10}-1)$, where the sum is over the integers $j$ with $0\\le j<10$ and $R_j\\equiv 10\\pmod{13}$.","answer":36,"answer_str":"036","tier":"AIME Hard"} {"id":"aimepp-hard-0095","problem":"A simple graph on $6$ labeled vertices is chosen uniformly from all connected such graphs. The probability that it has exactly $6$ vertices of odd degree and exactly $0$ triangles is $p/q$ in lowest terms. Let $Z$ be the least nonnegative residue of $p+q$ modulo $1000$. Put $L=Z+27$. Define $G(n,0)=1$, $G(0,k)=0$ for $k>0$, and $G(n,k)=G(n-1,k)+4^{n-k}G(n-1,k-1)$. Find the least nonnegative residue modulo $1000$ of $G(L,12)+7G(L,11)$.","answer":328,"answer_str":"328","tier":"AIME Hard"} {"id":"aimepp-hard-0096","problem":"Two walkers move simultaneously on the lattice, each taking one unit north or east step per second. The lower walker goes from $(0,0)$ to $(10,7)$, and the upper walker goes from $(0,2)$ to $(10,9)$. After every equal number of steps, their current vertices must be distinct. A turn is a change of direction by either walker. Let $Z$ be the least nonnegative residue modulo $1000$ of the number of ordered pairs of walks of such paths that have exactly $12$ turns in total and have the lower path visit exactly $6$ vertices on the line $y=x$, counting its initial vertex. Put $H=Z+85$. Find the least nonnegative residue modulo $1000$ of the number of ordered pairs $(a,b)$ that satisfy $1\\le a