|
|
back to boardCommon Boardcode on 1475. Курочка-Ряба Posted by sergo 20 Oct 2024 02:39 Post the code for this task, or what is wrong in my code? import math from decimal import Decimal, getcontext, ROUND_CEILING getcontext().prec = 210 for _ in range(int(input())): H, l, h = map(int, input().split()) H = Decimal(str(H)) l = Decimal(str(l)) h = Decimal(str(h)) a = Decimal(str(math.sin(math.atan(H / l)))) d = Decimal("4") * h * a g = Decimal(((H * H) + (l * l)) ** Decimal("0.5")) lm = Decimal("0") rm = Decimal("1e200") for i in range(700): mid = (lm + rm) / Decimal("2") if (d * (mid + 1) * mid) <= g: lm = mid else: rm = mid print(rm.quantize(Decimal('1'), rounding=ROUND_CEILING)) Edited by author 20.10.2024 02:41 |
|
|