Last active
August 29, 2015 14:07
-
-
Save mbc9news/5af8413f5697d6746cd1 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.FileInputStream | |
object FreeCell { | |
def check(n : Float , d:Float ,g:Float) : Boolean = { | |
if((g == 100 && d != 100) || (g == 0 && d != 0)) | |
false | |
else{ | |
val tmp1 = (1 to n.toInt).toList.filter(n => 100%n == 0).map(100/_) | |
val tmp2 = 0 to 100 | |
(for ( x <- tmp1; y <- tmp2 if x*y <= 100) yield x*y).toSet.exists(_ == d) | |
} | |
} | |
def main(args:Array[String]) { | |
// Console.setIn(new FileInputStream("sample.in")) | |
Console.setIn(new FileInputStream("A-small-practice.in")) | |
val cases = readLine.toInt | |
(1 to cases) foreach {num=> | |
val Array(n,d,g) = readLine.split(" ").map(_.toFloat) | |
val res = if(check(n,d,g)) "Possible" else "Broken" | |
println(s"Case #$num: $res") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
large가 안풀린다....