[algogeeks] Re: Good Maths Question

2011-01-29 Thread sankalp srivastava
Yuo might wanna check out The latest codeforces beta round problem C . On Jan 28, 8:34 pm, nishaanth nishaant...@gmail.com wrote: @All... According to the constraints(SPOJ problem) wont this dp solution time out ? On Tue, Jan 25, 2011 at 12:23 AM, sankalp srivastava

Re: [algogeeks] Re: Good Maths Question

2011-01-25 Thread Shiv ...
Hi, Here is a solution I have coded- http://codepad.org/bPOoakm3 Please let me know if you see any errors. *Logic for decreasing numbers-* Number of 'n' digit valid numbers (say 2), starting with digit 'k' (say 5); will be sum of number of 'n' digit valid numbers starting with 'k-1' and number

Re: [algogeeks] Re: Good Maths Question

2011-01-25 Thread Shiv ...
If the below link does not work- http://codepad.org/MDoQ8Kry ~Shiv. ** Hi, Here is a solution I have coded- http://codepad.org/bPOoakm3 Please let me know if you see any errors. *Logic for decreasing numbers-* Number of 'n' digit valid numbers (say 2), starting with digit 'k' (say 5);

Re: [algogeeks] Re: Good Maths Question

2011-01-25 Thread juver++
@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

Re: [algogeeks] Re: Good Maths Question

2011-01-25 Thread abhijith reddy
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())

[algogeeks] Re: Good Maths Question

2011-01-25 Thread sankalp srivastava
Correct me if I'm wrong dp[i][j]=how many numbers of length i with the last digit j(int base 10) dp[0][j]=0 dp[i][0]=dp[i-1][0] , last digit can't be zero otherwise the number has i-1 digits , not j; now the recursion to pass from one state to the next dp[i][j]=dp[i-1][k]+1(for each value of k

[algogeeks] Re: Good Maths Question

2011-01-24 Thread juver++
DP and clarify your incorrect question. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread Manmeet Singh
What is incorrect in the given question, except the constraints not given. On Mon, Jan 24, 2011 at 4:03 PM, juver++ avpostni...@gmail.com wrote: DP and clarify your incorrect question. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread Manmeet Singh
Also has any one solved https://www.spoj.pl/problems/MONONUM/ with only DP. I would like to know the solution, as my solution works for small nos. and then the ratio reduces to a simple mathematical formula. On Mon, Jan 24, 2011 at 4:09 PM, Manmeet Singh mans.aus...@gmail.comwrote: What is

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread juver++
@fight incorrect - how to calculate the number of the decreasing *n*-digit integers to the increasing *n*-digit integers -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread Manmeet Singh
ok, i thought he wanted the both, but he means ratio i guess. So, its the same problem. On Mon, Jan 24, 2011 at 4:21 PM, juver++ avpostni...@gmail.com wrote: @fight incorrect - how to calculate the number of the decreasing *n*-digit integers to the increasing *n*-digit integers -- You

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread Manmeet Singh
@JUVER++ : One personal question. Is this algo groups paying you something or you among the admins :) :). As in every problem I find your name and with a superb solution. On Mon, Jan 24, 2011 at 4:26 PM, Manmeet Singh mans.aus...@gmail.comwrote: ok, i thought he wanted the both, but he means

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread juver++
@fight :) it's only for my pleasure :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread Logic King
hey, but what's the solution to the problem...how to calculate the ratio ?? On Mon, Jan 24, 2011 at 11:19 PM, juver++ avpostni...@gmail.com wrote: @fight :) it's only for my pleasure :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread Manmeet Singh
n / 9.0 + 1 for n 20 works, before that I apply a simple DP. even i want to know a gud DP based solution for the problem, with no formula used, as I have done. On Mon, Jan 24, 2011 at 11:43 PM, Logic King crazy.logic.k...@gmail.comwrote: hey, but what's the solution to the problem...how

Re: [algogeeks] Re: Good Maths Question

2011-01-24 Thread juver++
dp[i][j] - how many numbers of length i and with the last digit j. Apply the scheme to increasing and decreasing number, then find ratio. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to