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-03-17 17:30:14 RIVU DAS
Easy in python!!
2014-03-16 18:24:22 Bhavik
easy in java now since i did not knew how to use mod effectively earlier:)still a challenge for me in C/C++ !!
2014-03-16 17:33:33 NISHANT RAJ
in python no need to care about overflow
five line of code in python using chinese remainder theorem
2014-02-16 21:58:47 anonymous
nice one :) observe carefully the overflow situations and use multimod algorithm ......

Last edit: 2014-03-03 06:27:24
2014-01-12 16:53:24 anurag garg
I was trying to solve this problem from last 2 months but this time AC with 0.00sec...:)

Last edit: 2014-01-12 16:53:39
2013-09-13 21:25:06 opensuse
Nice Problem .. :)
2013-09-21 10:09:20 [Lakshman]
@$:D use 109546051211LL

Last edit: 2013-09-05 15:41:00
2013-08-30 18:56:17 super human
awesome question.....AC!!!
2013-08-29 00:28:55 $!:D
what data type to use to store MOD value ?
i m using unsigned long long and getting compilation error saying
"integer constant is too large for 'long' type"
any1 xplain plzz.. n suggest
2013-08-25 13:22:09 @looser@
what is output for n=1000000
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.