Skip to content

Instantly share code, notes, and snippets.

@mbc9news
Last active August 29, 2015 14:07
Show Gist options
  • Save mbc9news/5af8413f5697d6746cd1 to your computer and use it in GitHub Desktop.
Save mbc9news/5af8413f5697d6746cd1 to your computer and use it in GitHub Desktop.
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")
}
}
}
@mbc9news
Copy link
Author

large가 안풀린다....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment