Блог пользователя _Spongey

Автор _Spongey, история, 11 месяцев назад, По-английски

So, My approach was to find the first two numbers they are fibbonachi like for example 6, 8, 14, 22 let's call the first number n, and the second n... then the sequence is: n, m, n+m, n+2m...

My code 238882947 So I basically found the sequence of ns and ms k'th index (K is the length of the sequence given) and made a for loop to get every possible number that works for this solution it worked right for most test cases (In test#1 lol) and printed out the correct first and second numbers of the sequence

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
11 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

As Mentionned in the diagnosis u have an integer overflow problem .Integers in C++ have bounds (2 to the power of 31 -1) and the fibonacci sequence increases exponentially.

  • »
    »
    11 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    My bad, I saw that my answer was wrong on my ide... How do I fix this issue btw?

    • »
      »
      »
      11 месяцев назад, # ^ |
        Проголосовать: нравится +6 Проголосовать: не нравится

      U can long long in C++ so u get a bigger bound of integers (2 to the power of 63 -1) but it won't fix the issue as the fibonnaci sequence grow exponentially .Also the problems tells u to create a new fibonnaci sequence by fixing the first and second element but in ur code u assumed they are one

»
11 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Solved it, 239474314