FIBSUM - Sum of Fibonacci numbers

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

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

hide comments
2013-11-30 17:26:59 Mitch Schwartz
The real top score is 37 in Bash by Nabb at http://www.spoj.com/SHORTEN/ranks/FIBSUM/ .
2013-11-30 17:26:59 Aditya Pande
got it in 84b in AWK
81b in RUBY

Last edit: 2012-12-26 08:12:22
2013-11-30 17:26:59 Sourabh Singh
@HWK can u tell me ppl who got ac in c use scanf/printf or there is some smaller way to i/o ??? plz...

Last edit: 2012-03-19 20:10:12
2013-11-30 17:26:59 Paras Sharma
stuck at 116 in perl :'(

Edit: reached 118 with python also. Can't decrease size any further. I guess there is some trick for this.

Last edit: 2012-02-19 10:24:54
2013-11-30 17:26:59 Allada Revanth Kumar
uffh.....152 in python :( please help me

Last edit: 2012-01-30 06:14:29
2013-11-30 17:26:59 HWK
@Wakarimasen lol: You can reach 57 bytes.
2013-11-30 17:26:59 Grandmaster
:'( for me solution in c++ seems impossible ..
2013-11-30 17:26:59 HWK
@XeRon!X: 40 Bytes. Not awk but Bash.
Nabb reached 39 bytes. Shinh could also but obviously he ignored a special trick.
2013-11-30 17:26:59 XeRoN!X
@HWK, what's your best solution. If i am allowed to ask -> Is it using awk?

Last edit: 2011-04-15 04:25:01
2013-11-30 17:26:59 HWK
@.:: Debanjan ::.: The algo of calculating the sums is okay. Thus your Python-solution is almost the same as my own. But some people have optimized the calculation of the fibs.
The same holds for C.

Re(debanjan):Thank you very much :-)

Last edit: 2011-04-17 11:01:48
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.