Non-Fibo

4.2

8 votes
Mathematics, Medium, Open, Approved, Number Theory
Problem

Seeing the fame received by the Fibonacci numbers, the other Natural Numbers were feeling jealous. Therefore, to give them their shot at glory Mr. Non-Fibo now wants you to tell him the Nth- Non Fibonacci Number.

Input:

First line contains T which is the number of test cases.
T lines follow each with an integer N.

Output:

For each N output the Nth Non-Fibonacci number.

Constraints:

  • 1 ≤ T ≤ 105
  • 1≤ N ≤ 1015

Scoring:

  • 1 ≤ T ≤ 105,1 ≤ N ≤ 105 : ( 30 pts )
  • 1 ≤ T ≤ 105,1 ≤ N ≤ 109 : ( 30 pts )
  • 1 ≤ T ≤ 105,1 ≤ N ≤ 1015 : ( 40 pts )
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The first few Natural Numbers that are Fibonacci are : 1,2,3,5,8,13.. Thus the first few Natural Numbers that are not Fibonacci are 4,6,7,9,...

Editor Image

?