Google Code Jam - New Lottery Game
Ruby, 107

I expected this would be a much shorter program.

gets
loop{a,b,k=gets.split.map &amp;:to_i
puts"Case ##{$.-1}: #{[*0...a].product([*0...b]).count{|x,y|x&amp;y&lt;k}}"}


Explanation


The first line of input can be ignored.
$. is the last read line number.
[*0...x] is a quick way to turn the Range into an Array. It uses the splat operator (*). Note that the Range is an exclusive one (... instead of ..).
Array#count takes a block. It will only count the elements for which the block returns a truthy value.