require 'set' $buf = [] def fill_buf; (s = gets) ? $buf = s.chomp.split : break while $buf.empty? end def has_next; fill_buf; !$buf.empty? end def get; fill_buf; $buf.shift end def geti; get.to_i end def getf; get.to_f end def getss(n = nil); n ? Array.new(n) { get } : begin fill_buf; $buf.shift(1e9) end; end def getis(n = nil); get_ss(n).map(&:to_i) end def getfs(n = nil); get_ss(n).map(&:to_f) end while has_next n = geti cand = Set.new u = Math.sqrt(n+1).to_i (1..u).select { |k| n % k == 0 }.each do |k| cand << "#{k}#{n/k}" cand << "#{k}#{n/k}" end p cand.size end