# AtCoder Beginner Contest 169 A, B, C with ruby

4th. Since I solved the C problem last time, I licked it that I could do it this time, and I stumbled upon the basics of computer engineering.

## A problem

#### `abc169a.rb`

``````
ab = gets.chomp.split(" ").map!{|item| item.to_i}
puts ab * ab
``````

Just write.

## B problem

#### `abc169b.rb`

``````
n = gets.chomp.to_i
a = gets.chomp.split(" ").map!{|item| item.to_i}
num = 1
ans = 1
th = 10**18
a.sort!{|a,b| (-1)*(a <=> b)}
if a[n - 1] == 0
puts 0
exit
end
for num in 1..n do
ans = ans * a[num-1]
num = num + 1
if ans > th
puts "-1"
exit
end
end
puts ans
``````

It's an integer multiplication, but in order

1. If there is even one 0, 0
2. If it exceeds 10 ^ 18, immediately return -1 and finish.
3. Returns the product of all the elements Correct answer. With c, you need to check 2 carefully, but with ruby, you don't have to worry because it is an integer type and multiple-precision integers are used as needed. I wrote that it sorts in reverse order so that it gets caught in the check of 2 quickly, and checks whether the last element is 0 first, but a.include? (0) or a.min is enough. Don't forget to add! To sort destructively.

## C problem

#### `abc169c.rb`

``````
ab = gets.chomp.split(" ")
a=ab.to_i
b=((ab.to_s).delete(".")).to_i
ans = a*b/100
puts ans
``````

Multiply b by 100, calculate it as an integer with to_s, and divide it by 100. When I did it, I stepped on the pattern of repeating decimals in binary notation. Treat b as an integer and to_s is easy after removing the decimal point. I can't pass this either. I will devote myself.