問題一覧 > 通常問題

No.1260 Many Polynomials

レベル : / AI推定難易度 : 1700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 66
作問者 : PCTprobability / テスター : magsta
お気に入りにしたユーザー ProblemId : 5011 / 自分の提出
問題文最終更新日: 2020-10-16 21:28:39
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 270 (mathematics contest) (順位表) の他の問題:

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$.
Therefore, the answer is $(1+1)+(1+0)=3$.

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もしくは右上の雲マークをクリックしてアカウントを作成してください。