Submit | All submissions | Best solutions | Back to list |
FACTMUL - Product of factorials |
You need to find the product of first n factorials 1! * 2! * ... * n! modulo 109546051211.
Input
One integer n (1 <= n <= 10000000)
Output
The answer.
Example
Input:
5
Output:
34560
Added by: | Ashot Minasyan |
Date: | 2013-08-20 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
|
||||||||||
2015-09-30 01:11:22 Yogesh Chauhan
Want to learn something? Do it in CPP or C ;) |
||||||||||
2015-09-03 00:17:30 shantanu tripathi
nice one.. tle due to useless iterations after ***** .. (calculate urself :) ) |
||||||||||
2015-08-27 17:53:44
Nice One ! Really loved it and learnt a lot about modulo operations. Once you get the clue, then its just 8 lines of python code. For anyone having problems, just make use of the fact the anything multiplied to 0 is 0. So you have to only get to the point where product of factorials becomes 0 and break from that point. There is no need for further computation. In fact any further computation will result in a TLE or an error. Enjoy the problem :) |
||||||||||
2015-07-20 02:13:41 varun bumb
50! :) |
||||||||||
2015-07-19 12:20:51 Diksha Jaiswal
learnt something new :) |
||||||||||
2015-07-15 20:32:58
8 lines in python = AC in 0.29 sec without using crt only a single trick |
||||||||||
2015-06-19 13:13:34 Bhuvnesh Jain
to avoid overflow issues in c, c++, read topcoder tutorial on mulmod function implementation(multiplication to 2 long long and taking modulo)... |
||||||||||
2015-06-11 21:20:40 i_am_looser
Got AC using c++ ; ) |
||||||||||
2015-06-03 15:40:10 Mani Soni
go for python only as c++ and c both are giving wrong answer even after using long long |
||||||||||
2015-05-25 19:18:25 [Lakshman]
@Maroof Because of integer overflow. |