Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created January 15, 2017 15:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save whatalnk/315f4c6202e1c905504bc02b71eba500 to your computer and use it in GitHub Desktop.
AtCoder ABC #052 [Ruby]
a, b, c, d = gets.chomp.split(" ").map(&:to_i)
s1 = a * b
s2 = c * d
if s1 >= s2 then
puts s1
else
puts s2
end
n = gets.chomp.to_i
s = gets.chomp.split("")
x = 0
xs = [x]
s.each do |c|
if c == "I" then
x += 1
else
x -= 1
end
xs << x
end
puts xs.max
require 'prime'
a = 10**9+7
n = gets.chomp.to_i
h = Hash.new(0)
(1..n).each do |i|
x = Prime.prime_division(i)
x.each do |n, e|
h[n] += e
end
end
ret = 1
h.values.each do |i|
ret *= (i + 1)
end
puts ret % a
n, a, b = gets.chomp.split(" ").map(&:to_i)
xs = gets.chomp.split(" ").map(&:to_i)
tired = 0
(n-1).times do |i|
d = xs[i + 1] - xs[i]
tired += [d*a, b].min
end
puts tired
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment