-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcookie-clicker.cpp
48 lines (32 loc) · 1000 Bytes
/
cookie-clicker.cpp
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// link: https://code.google.com/codejam/contest/2974486/dashboard#s=p1
// name: Cookie Clicker Alpha
#include<cstdio>
#include<vector>
#include <limits>
using namespace std;
int main(){
FILE * inFile, * outFile;
inFile = fopen ("B-large.in","r");
outFile = fopen ("B-large.out","w");
int T;
fscanf(inFile,"%d",&T);
for(int t=0;t<T;++t){
double c, f, x;
fscanf(inFile, "%lf%lf%lf", &c,&f,&x);
double timeSpentOnFactories = 0.0;
int factoriesNum = 0;
double solution = x/2;
while(true){
double current_speed = 2 + factoriesNum*f;
timeSpentOnFactories += c/current_speed;
factoriesNum++;
current_speed = 2 + factoriesNum*f;
double current_solution = timeSpentOnFactories + x/current_speed;
if(current_solution < solution) solution = current_solution;
else break;
}
fprintf(outFile, "Case #%d: %lf\n", (t+1),solution);
}
fclose(inFile);
fclose(outFile);
}