問題一覧 > 通常問題

No.2363 k-bonacci

レベル : / AI推定難易度 : 1225 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 43
作問者 : SPD_9X2
お気に入りにしたユーザー ProblemId : 8913 / 自分の提出
問題文最終更新日: 2023-07-16 01:26:25
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

Problem Statement

You are given an integer $N$. Determine whether there exists an integer $k$ greater than or equal to 2 for which the claim "the integer $N$ is an element of the $k$-bonacci sequence" is true, and if one exists, find the smallest such value.


In this problem, a sequence $A$ is defined to be a $k$-bonacci sequence if and only if it satisfies all of the following conditions.

  •  $A$ is an infinite sequence with first term $A_1$, continuing as $A_1,A_2,A_3,\cdots$.
  •  If $i < k$ holds, then $A_i = 0$.
  •  If $i = k$ holds, then $A_i = 1$.
  •  If $i > k$ holds, then $A_i = A_{i-k} + A_{i-k+1} + \cdots + A_{i-1}$.

Input

$N$

  • All inputs are integers.
  • $1 \le N \le 10^{18}$

Output

If no integer $k$ satisfying the condition exists, print $-1$. Otherwise, print the smallest value of $k$ satisfying the condition.
Print the output on the first line, followed by a newline at the end.

Sample

Sample 1
Input
4
Output
3

4 does not appear in the 2-bonacci sequence, but it does appear in the 3-bonacci sequence.

Sample 2
Input
2915
Output
-1

Sample 3
Input
518929865644420416
Output
8

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。