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

Common Board

To MadPsyentist/Sam (1036) (+)
Posted by Algorist 7 Mar 2002 14:52
How do you use only 2x500 numbers???
Re: To MadPsyentist/Sam (1036) (+)
Posted by Sam Green 7 Mar 2002 15:15
In order to know how many d digits numbers which their sum is s, you
just have to know how many d-1 digits numbers which their sums are
s , s-1, s-2...s-9 , right?
Yes, of course. But(+)
Posted by Algorist 7 Mar 2002 16:52
Yes, this is how I solve the problem-> using DP, i count these cases.
But, I have to use long numbers. And there are two variants :
1) To have an array NxS of long numbers to store the possibilities
2) To use just recursion and not to remember anything.
But, bot cases are impossible. Because, the first will get Memory
Limit, the second- Time Limit. So, I tried to allocate memory
dinamically. However, timus (as well as my PC) does not work all
right with realloc() (in C). So, I cannot solve it that way. My
quesiton is, how do you manage to solve the problem with a 2x500
array???

10x in advance
Re: Yes, of course. But(+)
Posted by Sam Green 7 Mar 2002 18:25
You don't have to store all NxS.
All you have to store is S bignums for current d and another S for d-1.
And current d will be d-1 to next d (i.e. d+1)

should i show you pseudo code ?
Yes, I am so stupid :)) It's obvious, and the same is for Stones, Metro, etc :))
Posted by Algorist 7 Mar 2002 18:27
(+)
Posted by Sam Green 7 Mar 2002 19:24
"Ha ha , how could a stupid person solved many problems that I can't :)"
i don't want to say like this , it's like chatting
because this board mainly for questions and answers
... anyway , :)