import scala.annotation.tailrec import scala.io.StdIn object Problem036 { // 素因数分解 def primeFactorization(n: Long): List[Long] = { @tailrec def factor(n: Long, div: Long, result: List[Long]): List[Long] = { if (n < div * div) { n :: result } else if (n % div == 0) { factor(n / div, div, div :: result) } else { factor(n, div + 1, result) } } factor(n, 2, Nil) } def proc(n: Long): String = { val pf = primeFactorization(n) if (pf.length >= 3) "YES" else "NO" } def main(args: Array[String]) { val n = StdIn.readLong() val result: String = proc(n) println(result) } }