Created
October 23, 2017 09:15
Star
You must be signed in to star a gist
Code Festival 2017 予選 C
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.split("") | |
s.each_cons(2) do |x, y| | |
if x == "A" && y == "C" | |
puts "Yes" | |
exit | |
end | |
end | |
puts "No" |
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 | |
a = gets.chomp.split(" ").map(&:to_i) | |
odd = 1 | |
a.each do |x| | |
if x.even? | |
odd *= 2 | |
end | |
end | |
puts 3**n - odd |
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 | |
n = s.length | |
l = 0 | |
r = n - 1 | |
ans = 0 | |
while true | |
break if l >= r | |
if s[l] == "x" && s[r] == "x" | |
l += 1 | |
r -= 1 | |
elsif s[l] == "x" && s[r] != "x" | |
ans += 1 | |
l += 1 | |
elsif s[l] != "x" && s[r] == "x" | |
ans += 1 | |
r -= 1 | |
else | |
if s[l] == s[r] | |
l += 1 | |
r -= 1 | |
else | |
puts -1 | |
exit | |
end | |
end | |
end | |
puts ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment