Problem:
Problem J: No Story

Since I got tired to write long problem statements, I decided to make this problem statement short. For given positive integer L, how many pairs of positive integers a, b (a ≤ b) such that LCM(a, b) = L are there? Here, LCM(a, b) stands for the least common multiple of a and b.

Input

For each dataset, an integer L is given in a line. Input terminates when L = 0.

Output

For each dataset, output the number of pairs of a and b.

Constraints

1 ≤ L ≤ 1012

Sample Input

12
9
2
0

Output for the Sample Input

8
3
2

Solution in Scala (judge verdict: Accepted)


object Main extends App {
  import scala.io.StdIn._


  val prime = primes(1000000)
  solve

  def solve: Unit = {
    val l = readLong
    if (l == 0) return
    var exp = Nil: List[Int]
    var n = l
    var i = 0
    while (n != 1 && i < prime.length) {
      val p = prime(i)
      if (n % p == 0) {
        var e = 0
        while (n % p == 0) {
          n /= p
          e += 1
        }
        exp ::= e
      }
      i += 1
    }
    if (n != 1)  exp ::= 1
    println(calCombination(exp))
    solve
  }
  def calCombination(exponents: List[Int]): Long = {
    if (exponents.isEmpty) return 1
    val combinationMemo = Array.tabulate(exponents.length){_ ⇒ -1L}
    combinationMemo(0) = 1
    def sub(current: Int, exp: List[Int]): Long = {
      if (combinationMemo(current) == -1){
        combinationMemo(current) = sub(current - 1, exp.tail) * (2 * exp.head + 1)
      }
      combinationMemo(current)
    }
    def sub2(current: Int, exp: List[Int]): Long = {
      exp match {
        case Nil ⇒ 1
        case h::t ⇒ sub2(current - 1, t) + sub(current - 1, t) * h
      }
    }
    sub2(exponents.length, exponents)
  }
  def primes(upper: Int): Array[Int] = {
    val memo = Array.tabulate(upper + 1){_ ⇒ true}
    for (i ← 2 to math.sqrt(upper).toInt) {
      if (memo(i))
        for (j ← i * 2 to upper by i)
          memo(j) = false
    }
    (2 to upper).filter(memo).toArray
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
  }
}