|
|
back to boardCommon BoardTo MadPsyentist/Sam (1036) (+) How do you use only 2x500 numbers??? Re: To MadPsyentist/Sam (1036) (+) 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(+) 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(+) 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 :)) (+) "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 , :) |
|
|