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
hide comments
Mitch Schwartz:
2013-11-30 17:26:59
The real top score is 37 in Bash by Nabb at http://www.spoj.com/SHORTEN/ranks/FIBSUM/ . |
|
Aditya Pande:
2013-11-30 17:26:59
got it in 84b in AWK
|
|
Sourabh Singh:
2013-11-30 17:26:59
@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 |
|
Paras Sharma:
2013-11-30 17:26:59
stuck at 116 in perl :'(
|
|
Allada Revanth Kumar:
2013-11-30 17:26:59
uffh.....152 in python :( please help me Last edit: 2012-01-30 06:14:29 |
|
HWK:
2013-11-30 17:26:59
@Wakarimasen lol: You can reach 57 bytes. |
|
Grandmaster:
2013-11-30 17:26:59
:'( for me solution in c++ seems impossible .. |
|
HWK:
2013-11-30 17:26:59
@XeRon!X: 40 Bytes. Not awk but Bash.
|
|
XeRoN!X:
2013-11-30 17:26:59
@HWK, what's your best solution. If i am allowed to ask -> Is it using awk? Last edit: 2011-04-15 04:25:01 |
|
HWK:
2013-11-30 17:26:59
@.:: 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.
|
Added by: | HWK |
Date: | 2011-03-25 |
Time limit: | 1s |
Source limit: | 111B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |