forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
37 lines (34 loc) · 789 Bytes
/
Copy pathB.cpp
File metadata and controls
37 lines (34 loc) · 789 Bytes
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
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long LL;
void run() {
double C, F, X;
cin >> C >> F >> X;
double res = X / 2.0, now = 0.0, rate = 2.0;
while (now < res) {
now += C / rate;
rate += F;
res = min(res, now + X / rate);
}
cout.precision(7);
cout.setf(ios::fixed, ios::floatfield);
cout << res << endl;
}
int main() {
int k;
cin >> k;
FOR(c,1,k) {
cout << "Case #" << c << ": ";
run();
}
return 0;
}