#P1771. 方程的解

    ID: 729 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划,dp数学高精度递归NOI 导刊

方程的解

Description

Jiajia ran into a tough problem and asks you to help solve it. Consider the Diophantine equation a1+a2++ak1+ak=g(x)a_1 + a_2 + \cdots + a_{k-1} + a_k = g(x), where k2k \ge 2 and kNk \in \mathbb{N}^*, xx is a positive integer, and g(x)=xxmod1000g(x) = x^x \bmod 1000 (that is, the remainder of xxx^x modulo 10001000). The numbers xx and kk are given. Your task is to find the number of solution tuples in positive integers to this equation.

For example, when k=3,x=2k = 3, x = 2, the solutions are:

{a1=1a2=1a3=2\begin{cases} a_1=1\\ a_2=1\\ a_3=2 \end{cases} {a1=1a2=2a3=1\begin{cases} a_1=1\\ a_2=2\\ a_3=1 \end{cases} {a1=2a2=1a3=1\begin{cases} a_1=2\\ a_2=1\\ a_3=1 \end{cases}

Input Format

The input contains exactly one line with two positive integers separated by a space, namely k,xk, x.

Output Format

Output exactly one line with the number of solution tuples in positive integers.

3 2
3

Hint

  • For 40% of the testdata, ans1016\mathit{ans} \le 10^{16}.
  • For 100% of the testdata, k100k \le 100, x2311x \le 2^{31}-1, kg(x)k \le g(x).

NOI Journal 2010 Senior (01)

Translated by ChatGPT 5