def ascan; gets.split.map(&:to_i); end def scan; gets.to_i; end aa,bb,cc = ascan @a=aa @b=bb @c=cc def calc(x) x*x*x+@a*x*x+@b*x+@c end def divc(x) 3*x*x+2*@a*x+@b end def my_nice_function(x) (4.0/3.0*(@b-@a*@a)*x+8.0/3.0*(@c-@a*@b))/(3.0*x*x+2.0*x*@a+@b)+(3.0*x+@a)/9.0 end def newton(x) x = (x).to_f 52.times{ x = x-calc(x)/divc(x)# my_nice_function(x)# } x.round end chance = (-20..20).to_a li = [] while li.size<3 x0 = rand((-1e9.to_i)..(1e9.to_i)) x0 = chance.pop unless chance.empty? z = newton(x0) li << z li.sort!.uniq! end puts li*" "