Last active
January 29, 2017 02:15
-
-
Save whatalnk/a0830814875b09499e6670300abcd4d9 to your computer and use it in GitHub Desktop.
AtCoder ABC #053 [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
x = gets.chomp.to_i | |
if x < 1200 then | |
puts "ABC" | |
else | |
puts "ARC" | |
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
s = gets.chomp | |
a = s.index("A") | |
z = s.rindex("Z") | |
puts z - a + 1 |
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
# AC | |
n = gets.chomp.to_i | |
h = Hash.new(0) | |
gets.chomp.split(" ").each do |a| | |
h[a.to_i] += 1 | |
end | |
n_even = 0 | |
n_odd = 0 | |
h.each do |k, v| | |
if v.even? then | |
n_even += 1 | |
else | |
n_odd += 1 | |
end | |
end | |
if n_even.even? then | |
puts n_odd + n_even | |
else | |
puts n_odd + n_even - 1 | |
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
x = gets.chomp.to_i | |
d = x / 11 | |
r = x % 11 | |
if r == 0 then | |
puts d * 2 | |
elsif r < 7 then | |
puts d * 2 + 1 | |
else | |
puts (d + 1) * 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment