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
Aditya Kumar Akash:
2013-08-23 19:09:04
admin could you please tell what's wrong with my code ?
|
|
Robert Gerbicz:
2013-08-23 14:07:17
I've just setup a medium version of this problem. See FACTMULM. |
|
Miguel Oliveira:
2013-08-23 12:51:31
@Mehmet i guess it depends on the value of n. why don't you try it out and set a problem on spoj if it turns out to be an interesting problem? :) Last edit: 2013-08-23 12:51:42 |
|
[Lakshman]:
2013-08-23 08:39:30
@Mehmet Inal Yes I think solution is possible with given constraints and with prime mod value but with one condition mod should be less than 10^9+7 Last edit: 2013-08-23 10:51:16 |
|
mehmetin:
2013-08-23 01:27:04
Would a solution be possible if mod value was a prime, given the same constraints? |
|
[Lakshman]:
2013-08-22 19:15:37
MY algorithm also based on the same O(n) concept and my running time is 2.24. |
|
Federico Lebrón:
2013-08-22 17:25:01
Xsquare: This isn't the place to ask for help with problems. You can ask in the forum about them, or just keep trying to solve it by yourself. Writing in this area spoils the problem for others.
|
|
Xsquare:
2013-08-22 15:26:55
How can a simple O(n) solution get TLE? where n is even less than 6*10^5 in my code! |
|
Miguel Oliveira:
2013-08-21 23:29:33
@Lakshman, note that 109546051211 is not a prime, that's the twist. |
|
Xsquare:
2013-08-21 18:40:51
Am getting WA by simple precomputation.. Any think taken to be care of besides mod value getting negative? |
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 |