Didn't you notice that the upper limit of n has been increased to 1000 ?
I really don't notice that.
Because I have already downloaded the Problem and not go online to see what has been changed.
Next time I should be more careful.
But now it got TLE.
I just changed the Max from 1135 to 3000.
and better way to avoid TLE?
The code is deleted because I think it is no need to post it.
Not the code itself problem.
Last edited by Zhao Le on Tue Jan 27, 2004 9:10 am, edited 1 time in total.
AC makes me feels good,
But WA makes me thinks hard.
And you'll figure out why it gots TLE.
[Something like a hint] While you're computing 1000! you're computing all other factorial values as well... what's the reason to do same calculations several times?..
As far as i know, many contestent faces problems compiling and running with an array of [1000][2600].
It is memory limit exceeded.
Even sometimes it doesn't take the input and if you are compile with VC++ 6.00, it will show an error msg and exit.
It you use cygwin you will again get memory dump error.
If you try to generate all instantly you will get tle.
If you try to generate only those neede for input(memoiztion) you will again get tle as i think they had given all the test cases from 1-1000..or something like that.
So, many methods to solve the problem will get problem.
--
Anupam
"Everything should be made simple, but not always simpler"
hey some one help me plizzzzzzz . i am getting wa at this after rejudgement . is there any tricky input . i hate to paste code but i am really very confused with this prob. i know that the prob statement has changed and it is changed to 1000 instead of 500. here is part of my code .
Riyad wrote:hey some one help me plizzzzzzz . i am getting wa at this after rejudgement . is there any tricky input . i hate to paste code but i am really very confused with this prob. i know that the prob statement has changed and it is changed to 1000 instead of 500. here is part of my code .
[cpp]BINT result[1002];[/cpp]
This problem hasn't any tricky input. Make sure it outputs correct answers for any integer from 0 upto 1000. Make also sure that BINT handles the result for 1000 which has more that 2500 digits...
Zhao Le:
I don't really know much about DP except using Matrix
How do you use matrix to find factorials?
Btw for this problem would there be TLE/MLE if we just precalculate all factorials and store the numbers in arrays? I haven't tried this yet but if the memory used is not too great it sounds like a good solution...
Precalculation works fine. Of course you shouldn't calculate each n! alone, you should compute n! as n*(n-1)! (the value (n-1)! is already stored in your precomputation table).