問題一覧 > 通常問題

No.1268 Fruit Rush 2

レベル : / AI推定難易度 : 2000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 129
作問者 : stoq / テスター : hanyu
お気に入りにしたユーザー ProblemId : 4447 / 自分の提出
問題文最終更新日: 2020-10-23 23:44:15
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 271 (順位表) の他の問題:

Problem Statement

The Fibonacci sequence $\{F_i\}$ is the sequence defined by $F_0 = F_1 = 1, \ F_{i+2} = F_{i+1} + F_i \ (i \geq 0)$. A number contained in the Fibonacci sequence is called a Fibonacci number.

There are $N$ fruits, and the freshness of the $i$-th fruit is $F_{A_i}$.
Here, $A_i$ is a positive integer; in particular, $A_i \neq 0$. Also, if $i \neq j$, then $A_i \neq A_j$.

Hanyu will choose at least $1$ and at most $N$ of these fruits to make mixed juice.
Since Hanyu loves Fibonacci numbers, she wants to choose the fruits so that the sum of the freshness of the chosen fruits is again a Fibonacci number.
Find the total number of such ways to choose the fruits. (It can be proved that the answer does not exceed $10^{18}$ under these constraints.)

Two ways of choosing fruits are considered different if there exists a fruit that is chosen in one but not chosen in the other.

Input

$N$
$A_1\ A_2\ \dots \ A_N$

  • All inputs are integers.
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq A_i \leq 10^{18}$
  • If $i \neq j$, then $A_i \neq A_j$.

Output

Output the total number of ways to choose the fruits so that the sum of their freshness is a Fibonacci number.

Sample

Sample 1
Input
3
3 4 5
Output
5

The freshness values of the fruits are $F_3=3,F_4=5,F_5=8$, and the following 5 ways satisfy the condition. (Typo corrected on 2020/10/23 23:43.)

  • $3 = F_3$
  • $5 = F_4$
  • $8 = F_5$
  • $3+5 = F_5$
  • $5+8 = F_6$

Sample 2
Input
4
1 10 100 1000
Output
4

Sample 3
Input
8
3 1 4 15 9 2 6 5
Output
17

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