import scala.annotation.tailrec import scala.io.StdIn object Problem002 { // 素因数分解 def primeFactorization(n: Int): List[Int] = { @tailrec def factor(n: Int, div: Int, result: List[Int]): List[Int] = { 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: Int): String = { val pf = primeFactorization(n) val group = pf.groupBy(x => x).map(x => x._2.size) val win = group.reduce(_ ^ _) != 0 if (win) "Alice" else "Bob" } def main(args: Array[String]) { val N = StdIn.readInt() val result = proc(N) println(result) } }