FACTMUL - Product of factorials

no tags 

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
saumya: 2014-08-28 06:45:26

n c++/c used mod value equal to 109546051211LL but was getting WA even then :( ... in python the same code got accepted :P..

sarelfeniel: 2014-06-27 22:20:06

Fantastic problem. Really brings together a lot of ideas that are useful for many Spoj problems.

[Lakshman]: 2014-05-31 21:25:16

Yes there is, CRT(Chinese remainder theorem) and prime power dividing factorial.

Last edit: 2014-05-31 22:06:48
Rahul Ranjan: 2014-05-31 15:53:22

Someody pls check my solution : http://ideone.com/U97WEX
I m getting WA!!!

lovecode: 2014-05-22 03:33:47

this problem is easy in python there is only 5 line code.......just think

lovecode: 2014-05-22 03:31:27

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

lovecode: 2014-05-22 03:27:11

in c++/c use mod value equal to 109546051211LL this cause me 5 compilation error

Abhinav Jain: 2014-05-20 16:06:31

Someody pls check my solution : http://ideone.com/hspb2z
I m getting WA!!!

ivar.raknahs: 2014-05-14 10:59:01

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
zai zai: 2014-03-19 17:38:29

worst case n=587116
my computer: 0.08s
spoj: tle ???


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