Factorial Array
-
kevin_atienza 7 years ago -
Abhinav36 7 years ago It would be nice if you guys act quick when somebody gives major hints and delete the comment .
-
marton_antoni 7 years ago Would be even better to use pre-moderated forums for competitions.
-
-
-
xuanyu_wang 7 years ago Here is a fact: even you do type 1 operation by adding 1 to each number in the range, the needed time beyond the time limit. So, take more considerations.
-
Manikanta2498 7 years ago any clue for this fact :/
-
-
NiceBuddy 7 years ago Its depressing when the code working perfectly, and only two tests passes. Even after using DP for factorials and different algorithmic functions for better efficiency, I still could not pass all. :(
-
vds_tanuj4567 7 years ago [deleted]
-
TMW98 7 years ago same used dp for factorials and other things but still two cases passed :'(
-
-
anshumanc007 7 years ago see...factorial is not a problem here...no of operation may be the problem...
-
ketakilolage97 7 years ago yeah, time runs out for the other cases.
-
-
eugalt 7 years ago Here is my approach.
For each value less than 40 maintain an ordered array of indices such that .
For operation 1 we need to replace a range of indices in each array with the corresponding range of array , for operation 2 we take the sum of times the length of the range of the corresponding array for all , for operation 3 we delete the index from an array if the previous value was less than 40 and insert the index into an array if the new value is less that 40.
-
stringray 7 years ago cool approach,
-
jhaight 7 years ago Thanks for sharing. How did you realize that values >= 40! will add 0 to the result? Is there some insight that led to this? I don't think I'd ever have arrived at that discovery on my own.
-
eugalt 7 years ago The first thing you notice is the strange modulus value, which is normally a large prime (), not a power of 10. Then you observe that when computing a factorial by multiplying consecutive numbers each time you hit a multiple of you add trailing 0's to the product. , so among the numbers from 1 to 40 we have 8 multiples of 5, one of which is , and thus has 9 trailing 0's.
Although there is a shortcut - come to the discussion area at the right moment and see some kind soul sharing this information for free. :)
-
-
-
S1LV3R_J1NX 7 years ago only 1st test case is passed and 1 test case failed and rest are T.O. I am using python any suggestions?
-
ASHWIN_18 7 years ago ur logic is wrong....... im getting all except two as timeout
-
S1LV3R_J1NX 7 years ago Where am I gng wrong?
-
ojhasaurabh2099 7 years ago how did you do it??
-
-
Sort 46 Discussions, By:
Please Log In in order to post a comment