import java.util.Scanner object Problem250 { def proc(dxt: Seq[(Int, Int, Long)]): Seq[String] = { for ((d, x, t) <- dxt) yield { val cnt: BigDecimal = (d, x) match { case _ if d >= 27 && x >= 27 => Long.MaxValue // 計算量削減 case _ => ncr(x + d - 1, d - 1) } if (t >= cnt) "AC" else "ZETUBOU" } } def ncr(n: BigDecimal, r: BigDecimal): BigDecimal = { val numer: BigDecimal = (n to n - r + 1 by -1).product val denom: BigDecimal = (r to 1 by -1).product (numer / denom).setScale(0, scala.math.BigDecimal.RoundingMode.HALF_UP) } def main(args: Array[String]) { val sc = new Scanner(System.in) val query = sc.nextInt() val dxt = Seq.fill(query)(sc.nextInt(), sc.nextInt(), sc.nextLong()) val result = proc(dxt) result.foreach(println) } }