class PiggyBank attr_reader :l, :m, :n def initialize(l: 0, m: 0, n: 0) @l, @m, @n = l, m, n @bill1000 = 0 end def datainput begin @l = Integer(gets.chomp) @m = Integer(gets.chomp) @n = Integer(gets.chomp) rescue end end def moneyexchange(coin100, coin25, coin1) # 1円 coin25 += coin1 / 25 coin1 = coin1 % 25 # 25円 coin100 += coin25 / 4 coin25 = coin25 % 4 # 100円 @bill1000 += coin100 / 10 coin100 = coin100 % 10 [coin100, coin25, coin1].inject(:+) end def dataoutput puts moneyexchange(@l, @m, @n) end def run datainput dataoutput end end if $0 == __FILE__ PiggyBank.new.run end