-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCookies.py
More file actions
25 lines (25 loc) · 793 Bytes
/
Cookies.py
File metadata and controls
25 lines (25 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
f = open("file.txt")
for i in range(int(f.readline())):
params = f.readline().split(" ")
farmCost = float(params[0])
farmProductivity = float(params[1])
neededCookies = float(params[2])
currentProductivity = 2
currentBest = 0
newBest = neededCookies/currentProductivity
farms = 1
while True:
currentBest = newBest
time = 0
currentProductivity = 2
for j in range(farms):
time += farmCost/currentProductivity
currentProductivity += farmProductivity
newBest = time + neededCookies/currentProductivity
if (newBest >= currentBest): break
farms += 1
caseOut = "Case #%i: %.7f" % (i+1, currentBest)
a = open("out.txt", 'a')
a.write(caseOut + "\n")
a.close()
f.close()