def lscan; gets.split.map(&:to_i); end def fibo(n) return 1 if n <= 0 a1 = 1 a2 = 0 a3 = 0 n.times do b1 = a2 + a1 b2 = a3 + 0 b3 = 0 + a1 a1,a2,a3=b1,b2,b3 # p [a1,a2,a3] end a1 end def solve(n,x,y) return 1 if n <= 2 return solve(n,y,x) if x > y x -= 1 if x == 1 y += 1 if y == n return 0 if y - x <= 1 fibo(y-x-2) end n,x,y = lscan # (1..n).each do |x| # (1..n).each do |y| # a = (1..n).to_a.permutation(n).count {|li| # li[0] == x && li[-1] == y && li.each_cons(2).all?{|a, b| (a-b).abs <= 2} # } # a -= solve(n,x,y) # printf "%3d", a # end # puts # end p solve(n,x,y)