Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created March 10, 2017 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/a9b2ac554ec5dea5e4b5747f8847bc5c to your computer and use it in GitHub Desktop.
Save whatalnk/a9b2ac554ec5dea5e4b5747f8847bc5c to your computer and use it in GitHub Desktop.
AtCoder ARC #066 / ABC #050 [Ruby]
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
if n.even? then
ref = ((1..(n-1)).step(2).to_a * 2).sort
ans = 2**(n/2) % (10**9 + 7)
else
ref = ((2..(n-1)).step(2).to_a * 2 + [0]).sort
ans = 2**((n-1)/2) % (10**9 + 7)
end
if a == ref then
puts ans
else
puts 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment