@above
A slight correction in the above code, inside the while loop..
while(++iter < N)
{
for (int i = 8; i > 0 ; --i)
{
A[i]+= A[i-1];
totalCount +=A[i];
}
totalCount+=1;
}
On Dec 27, 9:34 pm, Lucifer <[email protected]> wrote:
> As you are looking for a dp app...
>
> @ Non-Decreasing Digits
>
> Say the no. of digits is N..
> Lets take an array A[9] to store the individual intermediate counts...
>
> if (N > 1)
> {
> int iter = 0;
> int totalCount = 10; // this is when N = 1 ...
>
> for (int i=0; i < 9; ++i)
> A[i] = 1;
>
> while(++iter < N)
> {
> for (int i = 8; i > 0 ; --i)
> {
> A[i]+= A[i-1];
> totalCount +=A[i];
> }
> }
> printf("%d", totalCount);}
>
> else
> printf("%d", N==1 ? 10 : 0);
>
> On Dec 27, 6:58 pm, kumar rajat <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi
> > I have jus started to learn DP and I have coded the standard
> > algorithms(LCS,etc).
> > I have been trying these problems in SPOJ:
>
> >http://www.spoj.pl/problems/NOVICE63/http://www.spoj.pl/problems/NY10E/
>
> > I understand these may be solved elegantly using DP,but I dont get to
> > code the same.
> > Can any1 help me how to solve these types of problems using DP?
> > Any help regarding the same will be greatly appreciated.
--
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.