Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
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
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
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