Skip to content

Instantly share code, notes, and snippets.

@gabrielslau
Created January 21, 2013 02:14
Show Gist options
  • Save gabrielslau/4583153 to your computer and use it in GitHub Desktop.
Save gabrielslau/4583153 to your computer and use it in GitHub Desktop.
distancia_cidades = gets.to_i # km
velocidade_o1 = gets.to_i # km/h
velocidade_o2 = gets.to_i # km/h
tempo_operacao = gets.to_f # h
valor_litro_combustivel = gets.to_f
custo_onibus_parado = gets.to_f
# para So1 = So2 (quando ambos estiverem no mesmo ponto)
# tempo para o encontro
tempo_de_encontro = distancia_cidades.to_f / (velocidade_o1 + velocidade_o2).to_f
# local do encontro ( utilizando a partida em C1 )
ponto_encontro = velocidade_o1 * tempo_de_encontro
# ponto_encontro = 200 - (velocidade_o2 * tempo_de_encontro)
litros_combustivel_o1 = (ponto_encontro*2) / 10
litros_combustivel_o2 = ((distancia_cidades - ponto_encontro)*2) / 10
tempo_total_operacao = (tempo_de_encontro * 2) + tempo_operacao
custo_total = (custo_onibus_parado * tempo_total_operacao * 2) + ( litros_combustivel_o1 + litros_combustivel_o2) * valor_litro_combustivel
puts "%.1f" % ponto_encontro
puts "%.3f" % litros_combustivel_o1
puts "%.3f" % litros_combustivel_o2
puts "%.1f" % tempo_total_operacao
puts "%.2f" % custo_total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment