Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created January 10, 2016 08:51
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/62920270147e01c33b24 to your computer and use it in GitHub Desktop.
Save whatalnk/62920270147e01c33b24 to your computer and use it in GitHub Desktop.
AtCoder ABC #008
s, t = gets.chomp.split(" ").map(&:to_i)
puts t - s + 1
n = gets.chomp.to_i
res = {}
n.times do
name = gets.chomp
if res.key?(name) then
res[name] += 1
else
res[name] = 1
end
end
puts res.key(res.values.max)
n = gets.chomp.to_i
cc = readlines.map(&:to_i)
res = 0.0
cc.each do |c|
k = 0
cc.each do |f|
k += 1 if c % f == 0
end
if k.even? then
res += (k / 2.0) / k
else
res += ((k + 1) / 2.0) / k
end
end
puts res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment