FIBSUM - Sum of Fibonacci numbers

no tags 

Given the ith (1<=i<=35) Fibonacci number Fi calculate the sum of the ith till i+9th number Fi+Fi+1+...+Fi+9 and the last digit of the i+246th one Fi+246.
Be careful: Your solution mustn't exceed 111 bytes. But rather half of it should be more than enough.
Score is source length.

Input

In the first line the number of testcases N<=100, then N lines with one positive integer i.

Output

One line with "Fi+Fi+1+...+Fi+9+last digit of Fi+246" for each i.

Example

Input:
2
1
35 Output: 146
1821381552

hide comments
:(){ :|: & };:: 2013-11-30 17:26:59

@HWK: Could you please check my solution and tell me if I have hit the optimum trick?

HWK: 2013-11-30 17:26:59

@XeRon!X: Congratulation!
But that's what I said before. Therefore I've changed max of i and source limit. With i<=64 you wouldn't have done it.
By the way: My 100 bytes solution is almost identical to your 99.

Last edit: 2011-03-30 11:49:36
XeRoN!X: 2013-11-30 17:26:59

I was wrong, can be solved in 99B in C :)

HWK: 2013-11-30 17:26:59

@hallvabo: That's right. Changed.
@ADMIN: Why? For e.g. Python 140 bytes wouldn't be a challenge. You also can solve it in Ruby. I wrote a quick and dirty solution with 73 bytes.

Last edit: 2011-03-29 10:35:51
germinating: 2013-11-30 17:26:59

can the source limit be increased to 140 bytes final :)

Hallvard Norheim Bø: 2013-11-30 17:26:59

Example input line three (i=64) conflicts with the requirement 1<=i<=35.

HWK: 2013-11-30 17:26:59

Sorry, I meant the source limit. I've corrected it.
@XeRon!X: In addition I've changed source limit to 111 and maximum of i to 35. So a solution in C is possible. I wrote one with 100 bytes. Now it's your turn. ;-)
@numerix: You're on a good way, but it could be better. My Python solution before publication requires 72 bytes, my best non-Python solution 41.

XeRoN!X: 2013-11-30 17:26:59

Time limit is fine. I was referring to source limit only. Anyways, i'll try in some other language.

HWK: 2013-11-30 17:26:59

Yes, difficult or impossible.
But my thoughts were:
1. With a bigger source limit the task wouldn't be a challenge.
2. C has an advantage in many SPOJ-tasks, why not here a disadvantage.

Last edit: 2011-03-28 18:44:04
XeRoN!X: 2013-11-30 17:26:59

99B in C is very difficult. Consider to increase the limit.


Added by:HWK
Date:2011-03-25
Time limit:1s
Source limit:111B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All