-
Notifications
You must be signed in to change notification settings - Fork 0
/
1137 - Expanding Rods.cpp
124 lines (118 loc) · 2.69 KB
/
1137 - Expanding Rods.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*8<{==========~ BEGIN TEMPLATE ~============>8*/
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.cpp"
#else
#define dbg(...)
#endif
#define endl '\n'
#define fastio \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define all(j) j.begin(), j.end()
#define rall(j) j.rbegin(), j.rend()
#define len(j) (int)j.size()
#define rep(i, a, b) \
for (common_type_t<decltype(a), decltype(b)> \
i = (a); \
i < (b); i++)
#define rrep(i, a, b) \
for (common_type_t<decltype(a), decltype(b)> \
i = (a); \
i > (b); i--)
#define trav(xi, xs) for (auto &xi : xs)
#define rtrav(xi, xs) \
for (auto &xi : ranges::views::reverse(xs))
using ll = long long;
#define inte ll
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define emp emplace
#define ins insert
#define divc(a, b) ((a) + (b)-1ll) / (b)
using str = string;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vll2d = vector<vll>;
using vi = vector<int>;
using vi2d = vector<vi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vc = vector<char>;
using vs = vector<str>;
template <typename T, typename T2>
using umap = unordered_map<T, T2>;
template <typename T>
using pqmn =
priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using pqmx = priority_queue<T, vector<T>>;
template <typename T, typename U>
inline bool chmax(T &a, U const &b) {
return (a < b ? a = b, 1 : 0);
}
template <typename T, typename U>
inline bool chmin(T &a, U const &b) {
return (a > b ? a = b, 1 : 0);
}
/*8<============~ END TEMPLATE ~============}>8*/
void run();
int32_t main() {
#ifndef LOCAL
fastio;
#endif
cout<<fixed<<setprecision(10);
int T = 1;
cin >> T;
rep(t, 0, T) {
cout<<"Case "<<t+1<<": ";
dbg(t);
run();
}
}
const ld EPS=1e-9;
ld chordLenght(ld r, ld theta){
return 2.0 * r * sin(theta / 2.0);
}
template<typename T>
bool equals(T a, T b) {
if (std::is_floating_point<T>::value)
return fabs(a - b) < EPS;
else
return a == b;
}
void run() {
ld chord,n,c;cin>>chord>>n>>c;
ld arc= (1+n*c)*chord;
ld low=1e-9;
ld high=1e18;
ld defr;
for(;;){
auto r=(low+high)/2;
ld theta=arc/r;
ld curchord=chordLenght(r,theta);
if(equals(curchord,chord)){
defr=r;
break;
}
if(curchord<chord)
low=r;
else high=r;
}
ld theta=arc/defr;
ld h=defr*(1-cos(theta/2));
cout<<h<<endl;
}
/*8<
AC, geometry
>8*/