No.1260 Many Polynomials
タグ : / 解いたユーザー数 66
作問者 :
PCTprobability
/ テスター :
magsta
Problem Statement
We say that $f(x)$ is the "minimal polynomial of $B$ with respect to $A$" if a polynomial $f(x)$ with non-negative integer coefficients satisfies the following conditions. (21:27) Corrected "polynomial with integer coefficients" to "polynomial with non-negative integer coefficients".
- Condition $1$: $f(B)=A$
- Condition $2$: Among those satisfying Condition $1$, the sum of its coefficients is the smallest.
You are given a positive integer $N$.
For every integer $i$ between $2$ and $N$, inclusive, find the sum of the coefficients of the "minimal polynomial of $i$ with respect to $N$", and compute the total of these sums.
Since the answer can be very large, find it modulo $1000000007$.
Input
$N$
- $2 \le N \le 10^{12}$
Output
Print a newline at the end.
Sample
Sample 1
Input
3
Output
3
- The minimal polynomial of $2$ with respect to $3$ is $x+1$.
- The minimal polynomial of $3$ with respect to $3$ is $x$.
Sample 2
Input
10000000
Output
366605027
Print the answer modulo $1000000007$.
Sample 3
Input
12345654321
Output
265515257
Pay attention to the input constraints.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。