ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1011. Conductors

What can be wrong here?
Posted by Igor 17 Aug 2014 20:44
Submitted following solution, but WA on 1st test. I tried very different inputs and works fine actually.

def get_input_number
        gets.chomp.to_f
end

def calculate_conductors(low_percent, high_percent)
        (2..10000).each do |citizens|
                konduktors = (low_percent*citizens).ceil
                if (low_percent*citizens < konduktors) && (konduktors < high_percent*citizens)
                        return citizens
                end
        end
end

def prepare_input_and_go
        lower_border = get_input_number/100
        upper_border = get_input_number/100
        puts calculate_conductors(lower_border, upper_border)
end

prepare_input_and_go