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 newton(x) x = (x).to_f 50.times{ x = x-calc(x)/divc(x) } x.round end li = [] while li.size<3 z = newton(rand((-1e9.to_i)..(1e9.to_i))) li << z li.sort!.uniq! end puts li*" "