def ascan; gets.split.map(&:to_i); end gets aa = ascan.sort lis = [1] aa.each_cons(2) do |a,b| if (b-a).abs <= 1 lis[-1] += 1 else lis << 1 end end hoge = lis.map{|e| x=e%20;x>8 ? (x-8)%6 : x%4 }.reduce(:^) # p lis.map{|e| e%4} puts hoge == 0 ? :Second : :First #true => first @memo = {} def guchoku(set) return false if set.empty? return @memo[set] if @memo[set] set.each do |e| new_set = set.select{|x| (x-e).abs > 1} return @memo[set] = true if guchoku(new_set) == false end return @memo[set] = false end # 13.upto(13) do |i| # p [i+1, guchoku((1..(1+i)).to_a)] # end # # p guchoku(aa) # 1 2 3 4 5 6 7 8 9 # t t t f t t t f t # 0, 4, 8, 14, 20, 24, 28 # 4 6 6