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
hide comments
Yogesh Chauhan:
2015-09-30 01:11:22
Want to learn something?
|
|
shantanu tripathi:
2015-09-03 00:17:30
nice one.. tle due to useless iterations after ***** .. (calculate urself :) ) |
|
dwij28:
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 :) |
|
varun bumb:
2015-07-20 02:13:41
50! :) |
|
Diksha Jaiswal:
2015-07-19 12:20:51
learnt something new :) |
|
monish007:
2015-07-15 20:32:58
8 lines in python = AC in 0.29 sec
|
|
Bhuvnesh Jain:
2015-06-19 13:13:34
to avoid overflow issues in c, c++, read topcoder tutorial on mulmod function implementation(multiplication to 2 long long and taking modulo)... |
|
i_am_looser:
2015-06-11 21:20:40
Got AC using c++ ; ) |
|
Mani Soni:
2015-06-03 15:40:10
go for python only as c++ and c both are giving wrong answer even after using long long |
|
[Lakshman]:
2015-05-25 19:18:25
@Maroof Because of integer overflow. |
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 |