I remember solving this @ spoj Here is an O(1) solution
#!/usr/bin/python
def solve(n):
val=1
for i in range(1,9):
val*=(n+i)
return float((n+9)/9.0-(40320.0/val))
cases=int(raw_input())
while(cases):
cases-=1
n=int(raw_input())
print '%.6f'%(solve(n))
On Tue, Jan 25, 2011 at 6:28 PM, juver++ <[email protected]> wrote:
> @Skywalker your solution is ok. But is works only for the small value of n.
> Cause amount of desired numbers with n=10^6 digits is very big ))
> After n=27 there is a regularity for the ratio.
> However, here is more simplified dp - http://codepad.org/9bzFzDtV
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.