Задача GNY07B для spoj.pl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# http://www.spoj.pl/problems/GNY07B
GC.disable
arr = {
'kg' => ['lb',2.2046],
'lb' => ['kg',0.4536],
'l' => ['g',0.2642],
'g' => ['l',3.7854]
}
i = 0
Array.new(gets.chomp.to_i){ |elem|
gets.chomp.split.to_a
}.each{ |elem|
puts "%d %.4f %s" % [i+=1, arr[elem[1]][1]*elem[0].to_f, arr[elem[1]][0]]
}