blob: cd1fac371c28f5ec0626d6149a7ca295b0582f54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# pyright: strict
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))))
|