Artifact Content
Not logged in

Artifact 9caa644d5228a4f9afe09acf1f44a6fa1ddaa974


(****************************************************************************
 * Written in
 *    Alice 1.4
 *    http://www.ps.uni-saarland.de/alice/
 ****************************************************************************)

fun solve (n : int, k : int) : bool =
	let
		open Word
		infix 5 << andb
		val mask = (0wx1 << fromInt n) - 0wx1
	in
		(fromInt k) andb mask = mask
	end

fun main () =
	let
		fun readLine () =
			case TextIO.inputLine TextIO.stdIn of
			| NONE    => []
			| SOME(s) => map Int.fromString (String.tokens (fn x => x = #" ") s)

		fun parseOne c =
			case readLine() of
			| [SOME n, SOME k] => (c, (n, k))
			| _                => assert false

		fun spawn solveOne (c, inp) =
			(c, solve inp)

		fun printOne (c, ans) =
			print ("Case #" ^ Int.toString (c+1) ^ ": " ^ (if ans then "ON" else "OFF") ^ "\n")
	in
		case readLine () of
		| [SOME t] => List.app printOne (List.map solveOne (List.tabulate (t, parseOne)))
		| _        => assert false
	end

do main ()
do OS.Process.exit 0