Last active
August 29, 2015 14:07
-
-
Save waynejo/026dcad270ce3b51e956 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
object Main { | |
def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b) | |
def solve(n: BigInt, pd: Int, pg: Int): Boolean = { | |
if ((0 == pg && 0 < pd) || 100 == pg && 100 > pd) { | |
false | |
} else { | |
n >= 100 / gcd(pd, 100) | |
} | |
} | |
def main(args: Array[String]) { | |
val writer = new java.io.PrintWriter("a-large.out") | |
try { | |
process(io.Source.fromFile("A-large-practice (2).in").getLines)(writer.println) | |
} finally { | |
writer.flush() | |
writer.close() | |
} | |
} | |
def process(lineIn: Iterator[String])(lineOut: String => Unit) = { | |
for (i <- 1 to lineIn.next().toInt) { | |
val Array(n, pd, pg) = lineIn.next().split(" ") | |
lineOut(s"Case #$i: ${if (solve(BigInt.apply(n), pd.toInt, pg.toInt)) "Possible" else "Broken"}") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment