The Fibonacci Sequence is a mathematical sequence where the first and second terms are 1, and each term after that is the sum of the two previous terms. More formally, if
The modulo (or %
- for example, the line int a = 7%2;
in C++ will set a
to be 1.
You have found yourself at the first house of a long street. There are a total of
You can always walk from one house to an adjacent house (i.e. from house
At each house, there is also a trampoline that allows you to travel a larger distance. In particular, at the
You have been able to reverse-engineer a pattern of the values of
where
For reference purposes,
Please find the minimum number of minutes you need to travel from house
NOTE FOR PYTHON USERS: If your program receives TLE (time limit exceeded), you should try submitting using the PyPy interpreter: when you are submitting your code, try using "PyPy 3" or "PyPy 2" as the language, instead of "Python 3" or "Python 2".
Input Specification
The input will consist of one integer,
Output Specification
Please output the minimum number of minutes you need to travel from house
Constraints and Partial Marks
For
For the remaining
Sample Input 1
9
Sample Output 1
3
Explanation for Sample Output 1
The first
- Move
: Jump from house to house . This is possible as . - Move
: Jump from house to house . This is possible as . - Move
: Walk from house to house . This is possible as .
Every move takes 3
.
Sample Input 2
27
Sample Output 2
4
Explanation for Sample Output 2
One way to reach house
- Move
: Jump from house to house . This is possible as . - Move
: Jump from house to house . This is possible as . - Move
: Walk backwards from house to house . This is possible as . - Move
: Jump from house to house . This is possible as .
Comments