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-05-24 18:33:43 Maroof
same code gives WA in C++ and gets AC in python. Why is this Happening ?
2015-02-11 09:38:20 MaHmOuD.
What's the answer of n = 1000000?
2015-02-10 23:08:16 gamer496
In c++ intermediate result can overflow so it is advisable to use mulmod function
in python it's an issue
2015-02-05 16:56:31 Mercury
In C or C++ gave WA and got AC in Python 2.7 with same code.

[reply by cyclops: (As with the other similar comments,) all this tells is that you are not a careful programmer, and you have not taken the time to understand why your translation of code between languages gives different output for identical input. Possibly your C/C++ code suffers from overflow errors.]

Last edit: 2015-02-05 19:30:26
2015-02-05 12:00:53 Rahul
WA in C++, but same code gets accepted in python (:P)
2015-02-01 09:30:22 Raj Kumar Chauhan
thats nice problem..learn new thing :)
2015-01-09 12:00:15 Malinga
(n!)%mod=(n*(n-1)!)%mod...rest think.
2014-12-17 22:45:10 Sahil Dua
A great problem with a very simple hidden logic! :D
AC 0.34s
2014-10-10 18:26:46 Arpit Gupta
yeah! AC 0.00 !!! Can't believe i did that!!!
just a teeny tiny trick else child's play..

Last edit: 2014-10-11 07:35:38
2014-08-28 07:12:27 rajul
just a simple statement can cause TLE... else a piece of cake
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.