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
RIVU DAS: 2014-03-17 17:30:14

Easy in python!!

Bhavik: 2014-03-16 18:24:22

easy in java now since i did not knew how to use mod effectively earlier:)still a challenge for me in C/C++ !!

NISHANT RAJ: 2014-03-16 17:33:33

in python no need to care about overflow
five line of code in python using chinese remainder theorem

anonymous: 2014-02-16 21:58:47

nice one :) observe carefully the overflow situations and use multimod algorithm ......

Last edit: 2014-03-03 06:27:24
anurag garg: 2014-01-12 16:53:24

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
opensuse: 2013-09-13 21:25:06

Nice Problem .. :)

[Lakshman]: 2013-09-21 10:09:20

@$:D use 109546051211LL

Last edit: 2013-09-05 15:41:00
super human: 2013-08-30 18:56:17

awesome question.....AC!!!

$!:D: 2013-08-29 00:28:55

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

@looser@: 2013-08-25 13:22:09

what is output for n=1000000


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