parent
e9f829a6a8
commit
2aff65363f
1 changed files with 24 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||||||
|
from math import pow, ceil, floor |
||||||
|
|
||||||
|
lines = [l.split() for l in open("input.txt", 'r').read().splitlines()] |
||||||
|
races = [(int(lines[0][i]), int(lines[1][i])) for i in range(1,len(lines[0]))] |
||||||
|
#[(time, record)] |
||||||
|
|
||||||
|
#d = t * v |
||||||
|
#charge + t = time |
||||||
|
#t = time - charge |
||||||
|
#v = charge |
||||||
|
#d = (time - charge) * charge |
||||||
|
#d = -charge^2 + time*charge |
||||||
|
|
||||||
|
summa = 1 |
||||||
|
|
||||||
|
for race in races: |
||||||
|
a = -1 |
||||||
|
b = race[0] |
||||||
|
c = -race[1] |
||||||
|
rangeStart = floor((-b + pow((pow(b,2)-(4*a*c)),0.5)) / (2*a)) + 1 |
||||||
|
rangeEnd = ceil((-b - pow((pow(b,2)-(4*a*c)),0.5)) / (2*a)) - 1 |
||||||
|
summa *= (rangeEnd-rangeStart+1) |
||||||
|
|
||||||
|
print(summa) |
Loading…
Reference in new issue