@memo = {} def f(d, x) if d == 1 return 1 end if d == 2 return x + 1 end count = 0 (0..x).each do |i| if !@memo.key?([d - 1, i]) @memo[[d - 1, i]] = f(d - 1, i) end count += @memo[[d - 1, i]] end return count end q = gets.chomp.to_i q.times do d, x, t = gets.chomp.split(' ') d = d.to_i x = x.to_i t = t.to_i if f(d, x) <= t puts "AC" else puts "ZETUBOU" end end