22 lines
474 B
Python
22 lines
474 B
Python
#!/usr/bin/env python3
|
|
import math
|
|
import re
|
|
|
|
lines = (x.strip() for x in open("input.txt"))
|
|
times = []
|
|
records = []
|
|
|
|
for line in lines:
|
|
if line.startswith("Time"):
|
|
times = tuple(map(int, re.findall("\d+", line)))
|
|
else:
|
|
records = tuple(map(int, re.findall("\d+", line)))
|
|
|
|
result = 1
|
|
for t, r in zip(times, records):
|
|
pmin = (t-(t**2-4*r)**0.5)/2
|
|
pmax = (t+(t**2-4*r)**0.5)/2
|
|
result *= math.floor(pmax) - math.ceil(pmin) + 1
|
|
|
|
print(result)
|