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
Maroof: 2015-05-24 18:33:43

same code gives WA in C++ and gets AC in python. Why is this Happening ?

MaHmOuD.: 2015-02-11 09:38:20

What's the answer of n = 1000000?

gamer496: 2015-02-10 23:08:16

In c++ intermediate result can overflow so it is advisable to use mulmod function
in python it's an issue

Mercury: 2015-02-05 16:56:31

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
Rahul: 2015-02-05 12:00:53

WA in C++, but same code gets accepted in python (:P)

Raj Kumar Chauhan: 2015-02-01 09:30:22

thats nice problem..learn new thing :)

Malinga: 2015-01-09 12:00:15

(n!)%mod=(n*(n-1)!)%mod...rest think.

Sahil Dua: 2014-12-17 22:45:10

A great problem with a very simple hidden logic! :D
AC 0.34s

Arpit Gupta: 2014-10-10 18:26:46

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
rajul: 2014-08-28 07:12:27

just a simple statement can cause TLE... else a piece of cake


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