-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodejamB.cpp
More file actions
56 lines (54 loc) · 1.21 KB
/
Copy pathcodejamB.cpp
File metadata and controls
56 lines (54 loc) · 1.21 KB
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
49
50
51
52
53
54
55
56
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <stdlib.h>
using namespace std;
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,st,end) for(int i=st;i<end;i++)
#define db(x) cout << (#x) << " = " << x << endl;
#define mp make_pair
#define pb push_back
double c,f,x;
bool AreDoubleSame(double dFirstVal, double dSecondVal)
{
return std::fabs(dFirstVal - dSecondVal) < 1E-3;
}
double solve(double spent,double each){
//cout<<x/each<<"<"<<(c/each+(x/(each+f)))<<endl;
if((x/each)<(c/each+(x/(each+f)))){
// cout<<"\nleft\n";
return (spent+x/each);
}
else{
// cout<<"\nRight\n";
// cout<<"solve("<<spent<<","<<each<<")"<<endl;
return solve(spent+c/each,each+f);
}
}
int main(){
int t;
scanf("%d",&t);
for(int ca=1;ca<=t;ca++){
scanf("%lf%lf%lf",&c,&f,&x);
printf("Case #%d: ",ca);
printf("%.7lf\n",solve(0,2));
}
}