Last active
August 29, 2015 14:20
-
-
Save waynejo/8c5d881790b4b6144be4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.{FileOutputStream, FileInputStream} | |
import scala.annotation.tailrec | |
import scala.io.StdIn | |
object Main extends App { | |
//Console.setIn(new FileInputStream("example.in")) | |
Console.setIn(new FileInputStream("D-large-practice.in")) | |
Console.setOut(new FileOutputStream("D-large-practice.out")) | |
def solve(x: Int, r: Int, c: Int): Boolean = { | |
val s = r min c | |
val l = r max c | |
x match { | |
case _ if 0 != (s * l) % x => true | |
case 3 => s == 1 | |
case 4 => s <= 2 | |
case 5 => s <= 2 || (s, l) == (3, 5) | |
case 6 => s <= 3 | |
case _ => x >= 7 | |
} | |
} | |
val cases = StdIn.readLine().toInt | |
(1 to cases) foreach { n => | |
val Array(x, r, c) = StdIn.readLine().split(" ").map(_.toInt) | |
println(s"Case #$n: ${if (solve(x, r, c)) "RICHARD" else "GABRIEL"}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment