Time

18:15:11
22 May 2012
Version for print

Multifactorial

   The k-multifactorial of n  is denoted by fack(n) and is defined as the product of every positive number of the form nk * x, x = 0, 1, 2, … .

   A formal definition of multifactorial is:

   fack(n) = n, if k ≥ n;

   fack(n) = n * fack(nk), if k < n;

   You will be given n and k and have to evaluate the value of fack(n). If the result is strictly greater than 1018, you must print "overflow".


Specifications

   Input

   Two integers n and k (1 ≤ n, k ≤ 2 * 109).

   Output

   The value of fack(n). If it is strictly greater than 1018, print "overflow".


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 5
Complexity: 35% 51/78
Classes: Simple mathematics

Example

Example input

Sample 1
14 3

Sample 2
1000 2

Example output

Sample 1
12320

Sample 2
overflow


← MassiveNumbers Problems Rock, Paper, or Scissors? →