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

Автор pistone, 13 лет назад, По-английски

for me it wa quite a problem , since i strictly used C++ to solve it.

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

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

my fault , sorry 

actually the problem is :  finding the minimum c++ variable type(byte,short,int,long etc)  in which nth fibonacci number can be accomodated .
 
if it cant be accomodated in c++ standard var types then print  "BigInteger" .

  • 13 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    It is all the same, just use log2 instead of log10.

    However, since Fibonacci sequence grows fast, you can write program for direct computation.

    UPD: Or you mean "help me to write the program for Fibonacci sequence computation?"
13 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

You can just generate locally all those Fib numbers and remember n values: ai is such that Fai is a max number that fits in ith type.
After that just some if's.