PIB - Pibonacci
You might have heard of the Fibonacci numbers and of the number pi. If you let these two ideas merge, a new and esoteric concept comes into being: the Pibonacci numbers. These can be defined for real x>=0 by:
|P(x) = 1||for 0<=x<4|
|P(x) = P(x-1) + P(x-pi)||for 4<=x,|
where pi = 3.1415926535... In this problem, you are asked to compute P(x) for a given x.
Input file specification
The input file contains several non-negative integer numbers (less than 30000) each on a separate line. The last line contains -1 marking the end of the input file.
Output file specification
For each non-negative real number in the input file, output the corresponding Pibonacci number. If the Pibonacci number be more than 50 digits long, divide it on the consecutive lines, outputting 50 digits on each (the last line may contain less digits).
0 4 11 -1
1 2 20
Could I have the results for n=29 to n =50?
great problem, enjoyed it very much
It should not work. I did the same the first time around. If you analyze it, you'll see you will generate way to many intermediate values. You need to analyze call tree and deduce some formula from there. Definitively not an easy problem!
recursion with memorization not working... plz help
(1) Each integer in the input file is less than 30000. Number of test cases is small.