Advertisement
montimaj

COOKIE-CLICKER-ALPHA

May 5th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<vector>
  4. #include<algorithm>
  5. double gen_cookie_time(double c,double f,double x)
  6. {
  7.   if(x<=2)
  8.     return x/2.;
  9.   double f1=2,buy_time=0;
  10.   std::vector<double> v;
  11.   v.push_back(x/f1);
  12.   while(f1<=1e+7)
  13.   {
  14.     buy_time+=c/f1;    
  15.     f1+=f;
  16.     double wait_time=buy_time+x/f1;
  17.     v.push_back(wait_time);
  18.   }
  19.   return *std::min_element(v.begin(),v.end());
  20. }
  21. int main()
  22. {
  23.   int t;
  24.   std::cin>>t;
  25.   for(int i=1;i<=t;++i)
  26.   {
  27.     double c,f,x;    
  28.     std::cin>>c>>f>>x;
  29.     double time=gen_cookie_time(c,f,x);
  30.     printf("Case #%d: %.7lf\n",i,time);      
  31.   }
  32.   return 0;  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement