Created
January 15, 2017 15:40
Star
You must be signed in to star a gist
AtCoder ABC #052 [Ruby]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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