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
2014-08-28 06:45:26 saumya
n c++/c used mod value equal to 109546051211LL but was getting WA even then :( ... in python the same code got accepted :P..
2014-06-27 22:20:06 sarelfeniel
Fantastic problem. Really brings together a lot of ideas that are useful for many Spoj problems.
2014-05-31 21:25:16 [Lakshman]
Yes there is, CRT(Chinese remainder theorem) and prime power dividing factorial.

Last edit: 2014-05-31 22:06:48
2014-05-31 15:53:22 Rahul Ranjan
Someody pls check my solution : http://ideone.com/U97WEX
I m getting WA!!!
2014-05-22 03:33:47 lovecode
this problem is easy in python there is only 5 line code.......just think
2014-05-22 03:31:27 lovecode
Abhinav: i checked your solution but its not working for n=12345 i checked your solution gives "0" but correct answer is 39646138362 gud luck
2014-05-22 03:27:11 lovecode
in c++/c use mod value equal to 109546051211LL this cause me 5 compilation error
2014-05-20 16:06:31 Abhinav Jain
Someody pls check my solution : http://ideone.com/hspb2z
I m getting WA!!!
2014-05-14 10:59:01 ivar.raknahs
my pyth code took 1.80 sec and given time limit is 1 sec
strange huhh.
got AC though
--ans(Francky)--> There's several input files. Your time is cumulus of several times under 1s.

Last edit: 2014-05-14 11:49:48
2014-03-19 17:38:29 zai zai
worst case n=587116
my computer: 0.08s
spoj: tle ???
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.