ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1353. Milliard Vasya's Function

Any good method
Posted by jagatsastry 14 Feb 2008 14:07
Is there any good method other than precalculating and using the values stored?
Re: Any good method
Posted by jagatsastry 15 Feb 2008 00:00
I've got a good method. Use the following recurrence eqn and solve using DP.
num(n,s)=sigma(i=0 to 9){ ((s-i)>=0)?num(n-1, s-i):0}
n represents the number of digits and s represents the sum of digits.

NOTE: For those who got WA#9, you would not have initialized num[1][9]=1. Better checkout the whole 2d array once and verify that for s=81 output should be 1.



Edited by author 15.02.2008 00:14
Re: Any good method
Posted by namee 6 Jan 2009 20:52
I initialized num[1][9]=1 and i have AC