I think it surely will get MLE(Memory Limit Execeeded).Adrian Kuegel wrote: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).
as I memtioned above.
but how should I handle without Matrix?anupam wrote:I know you will get as I hope here are all he cases possible and even more than one ocurence for the same case.
I mean when first time 1000 appears I calcaulated but second time it appears what I should do?
use Matrix to store?(It will cause Memory Limit Excessed I think)
give me some hint or other.