WPC4E - Out of place

no tags 

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

 

 

 

 


hide comments
[Rampage] Blue.Mary: 2011-10-25 01:53:29

See this one (almost the same except the constants in the formula): http://www.spoj.pl/problems/COINS/. Moved into tutorial.

Walrus: 2011-10-24 22:57:35

n was larger. Test cases corrected. Sorry for inconvenience.

Muhammad Ridowan: 2011-10-24 22:34:28

Surely n is bigger. Same code just when I take n as 64 bit integer, WA becomes AC

:D: 2011-10-24 22:34:28

Are you sure n<=10^9, not bigger?


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