Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- #include<vector>
- #include<algorithm>
- double gen_cookie_time(double c,double f,double x)
- {
- if(x<=2)
- return x/2.;
- double f1=2,buy_time=0;
- std::vector<double> v;
- v.push_back(x/f1);
- while(f1<=1e+7)
- {
- buy_time+=c/f1;
- f1+=f;
- double wait_time=buy_time+x/f1;
- v.push_back(wait_time);
- }
- return *std::min_element(v.begin(),v.end());
- }
- int main()
- {
- int t;
- std::cin>>t;
- for(int i=1;i<=t;++i)
- {
- double c,f,x;
- std::cin>>c>>f>>x;
- double time=gen_cookie_time(c,f,x);
- printf("Case #%d: %.7lf\n",i,time);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement