WPC4E - Out of place

You are given a very simple problem, you need to evaluate the following function for a number of values of n.
F(0)=1
F(n) = F(n/2) + F(n/5) + F(n/7)

Input:
The first line contains number test cases T (T <= 100)
The next T lines contain a number n (n <= 10^9)

Output:
T lines each having values of F(n)

Sample I/O

Input
3
0
5
15

Output
1
9
21

 

 

 

 


Added by:Walrus
Date:2011-10-24
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Local Contest: WPC 4

hide comments
2011-10-25 01:53:29 [Rampage] Blue.Mary
See this one (almost the same except the constants in the formula): http://www.spoj.pl/problems/COINS/. Moved into tutorial.
2011-10-24 22:57:35 Walrus
n was larger. Test cases corrected. Sorry for inconvenience.
2011-10-24 22:34:28 Muhammad Ridowan
Surely n is bigger. Same code just when I take n as 64 bit integer, WA becomes AC
2011-10-24 22:34:28 :D
Are you sure n<=10^9, not bigger?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.