Successió de Fibonacci
Submit solution
Points:
10
Time limit:
5.0s
Memory limit:
256M
Author:
Problem types
Allowed languages
C#, Go, Java
La successió de Fibonacci comença amb els nombres 0 i 1, i a partir d'aquests, «cada terme és la suma dels dos anteriors».
Determina si una seqüència de nombres és una successió de Fibonacci.
Input Format
Una seqüència de \(N\) nombres enters. La seqüència acaba amb un \(-1\).
Constraints
\(-\)
Output Format
\(SI\) o \(NO\)
Sample Input 0
0 1 -1
Sample Output 0
SI
Sample Input 1
0 1 2 -1
Sample Output 1
NO
Sample Input 2
0 1 1 2 3 5 8 13 21 34 -1
Sample Output 2
SI
Sample Input 3
0 1 1 -1
Sample Output 3
SI
Sample Input 4
0 1 1 2 3 4 -1
Sample Output 4
NO
Sample Input 5
5 6 11 17 28 -1
Sample Output 5
NO
Autoria: Gerard Falcó
CC BY-NC-SA 4.0