AtCoder Beginner Contets C - Multiplication 3 Difficulty: 536
This theme, error due to floating point
wa1.rb
a, b = gets.split.map(&:to_f)
puts (a * b).floor
Since it is truncated, floor
is used, but WA
.
WA2
wa2.rb
a, b = gets.split.map(&:to_f)
puts ((a.to_i * (b * 100)) / 100).floor
Strategy to divide by 100
after100 times
, failure.
WA3
wa3.rb
a, b = gets.split.map(&:to_f)
puts ((a.to_i * (b * 100)) / 100).to_i
Try changing floor
to to_i
at the request of God.
WA4
wa4.rb
a, b = gets.chomp.split
puts ((a.to_i * (b.to_f * 100).to_i) / 100)
A strategy to convert the reception from standard input into a character string. AC
ac.rb
a, b = gets.chomp.split
puts ((a.to_i * (b.gsub!('.', '').to_i).to_i) / 100)
A strategy to give up to_f
by100 times
and delete the characters with the decimal point .
.
$ \ huge {success} $ </ font>
I don't know what was good and what was poor, but I was tired anyway.
** Addition ** Good articles have been posted
Recommended Posts