diff options
-rw-r--r-- | 6.py | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +from functools import reduce +from math import floor, sqrt +from operator import mul +from sys import stdin + + +def solve(time: int, distance: int): + root = (time - sqrt(time**2 - 4 * distance)) / 2 + first = floor(root + 1) + return time - 2 * first + 1 + + +inp = list( + zip( + *( + [int(s) for s in l.split(maxsplit=1)[1].split()] + for l in stdin.read().rstrip("\n").split("\n") + ) + ) +) + +print(reduce(mul, (solve(*i) for i in inp))) +print(solve(int("".join(str(i[0]) for i in inp)), int("".join(str(i[1]) for i in inp)))) |