Тюшев Максим, 321 ArbitPrec 4758
ПУТИЛОВ ГЕОРГИЙ КОНСТАНТИНОВИЧ ArbitPrec 5451
t1from decimal import Decimal, getcontextt1from decimal import Decimal, getcontext
2foo = input()2foo = input()
3func = lambda x: eval(foo)3func = lambda x: eval(foo)
4d = int(input())4d = int(input())
5getcontext().prec = d + 25getcontext().prec = d + 2
6x = [Decimal(-1.5), Decimal(1.5)]6x = [Decimal(-1.5), Decimal(1.5)]
7eps = Decimal(f'1E-{d + 1}')7eps = Decimal(f'1E-{d + 1}')
8length = lambda x: x[-1] - x[0]8length = lambda x: x[-1] - x[0]
9flag = func(x[0]) < 09flag = func(x[0]) < 0
10s = '{:.' + str(d) + 'f}'10s = '{:.' + str(d) + 'f}'
11while length(x) > eps:11while length(x) > eps:
12    t = (x[0] + x[-1]) / 212    t = (x[0] + x[-1]) / 2
13    if func(t) == 0:13    if func(t) == 0:
14        print(s.format(t))14        print(s.format(t))
15        break15        break
16    elif func(t) > 0 and flag or (func(t) < 0 and (not flag)):16    elif func(t) > 0 and flag or (func(t) < 0 and (not flag)):
17        x = [x[0], t]17        x = [x[0], t]
18    elif func(t) < 0 and flag or (func(t) > 0 and (not flag)):18    elif func(t) < 0 and flag or (func(t) > 0 and (not flag)):
19        x = [t, x[-1]]19        x = [t, x[-1]]
20else:20else:
21    print(s.format(x[1]))21    print(s.format(x[1]))
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op