Last active
September 19, 2015 02:29
-
-
Save parrot-studio/8fae30021b17177d4ba4 to your computer and use it in GitHub Desktop.
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
https://paiza.jp/poh/joshibato/ | |
kirishima.rb | |
https://paiza.jp/poh/joshibato/kirishima/result/4d6681fb | |
rio.rb | |
https://paiza.jp/poh/joshibato/tsubame/result/f494a598 | |
tsubame.rb | |
https://paiza.jp/poh/joshibato/tsubame/result/f494a598 |
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
goal = gets.to_i | |
map = gets.split(' ').map(&:to_i) | |
count = gets.to_i | |
results = [] | |
count.times do | |
i = gets.to_i | |
case results[i] | |
when :goal | |
puts 'Yes' | |
next | |
when :ng | |
puts 'No' | |
next | |
end | |
rsl = nil | |
before = {} | |
now = i + 1 | |
loop do | |
break if rsl | |
num = map[now - 1] | |
target = num.to_i + now | |
case | |
when target == goal | |
rsl = :goal | |
when target == now | |
rsl = :ng | |
when before[target] | |
rsl = :ng | |
else | |
before[now] = true | |
now = target | |
end | |
end | |
if rsl == :goal | |
puts 'Yes' | |
results[i] = :goal | |
else | |
puts 'No' | |
results[i] = :ng | |
end | |
end | |
exit |
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
coffee = 0.0 | |
water = 0.0 | |
gets.to_i.times do | |
m, num = gets.split(' ').map(&:to_i) | |
case m | |
when 1 | |
water += num.to_f | |
when 2 | |
coffee += num.to_f | |
when 3 | |
all = coffee + water | |
water -= (num.to_f * water / all) | |
coffee -= (num.to_f * coffee / all) | |
end | |
end | |
puts (coffee * 100 / (coffee + water)).floor |
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
str = gets | |
puts str.to_i + str[0].to_i + str[1].to_i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment