Skip to content

Instantly share code, notes, and snippets.

@shemul
Created November 5, 2014 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shemul/e018512b8b6707f57d7c to your computer and use it in GitHub Desktop.
Save shemul/e018512b8b6707f57d7c to your computer and use it in GitHub Desktop.
Google CodeJam - Cookie Clicker Alpha solve
// Code : Google Code Jam
// Problem : Cookie Clicker
// Code in C++
// Solved by ICONIX
#include <iostream>
using namespace std;
int main() {
double C, F, X;
cout << "Firm Price : " ;
cin >> C;
cout << "Firm Cookie Per second : ";
cin >> F;
cout << "Total outcome :";
cin >> X;
double time = 0,
cookiePerSecond = 2.0,
TotalTime = X/cookiePerSecond;
while(int t=5){
time = time + C/cookiePerSecond;
cookiePerSecond = cookiePerSecond + F;
if(X/cookiePerSecond + time < TotalTime){
//cout << m <<"\n";
TotalTime = time + X/cookiePerSecond;
}else{
break;
}
t--;
}
cout << "Lowest time :" << TotalTime <<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment