Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define endl "\n"
- using namespace std;
- using ll = long long;
- using ld = long double;
- using pii = pair<int, int>;
- constexpr int N = 1e5 + 5;
- int t, w, h, u, l, r, d;
- ld ans = 0, answer = 0;
- ld deg[N];
- void Solve(int id) {
- ans = 0;
- cin >> w >> h >> l >> u >> r >> d;
- ld cur = 1;
- if (h > d)
- for (int i = 1; i < l; i++) {
- ans += cur;
- cur /= 2;
- cur += cur * (d - 1) / i;
- }
- ans *= deg[d];
- answer = ans;
- ans = 0;
- cur = 1;
- if (w > r)
- for (int i = 1; i < u; i++) {
- ans += cur;
- cur /= 2;
- cur += cur * (r - 1) / i;
- }
- answer += ans * deg[r];
- if (r - l + 1 == w || d - u + 1 == h || l == 1 && u == 1)
- answer = 0;
- cout << "Case #" << id << ": " << fixed << setprecision(40) << answer << endl;
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- deg[0] = 1;
- for (int i = 1; i < N; i++)
- deg[i] = deg[i - 1] / 2;
- cin >> t;
- for (int i = 1; i <= t; i++)
- //auto start = chrono::high_resolution_clock::now();
- Solve(i);
- //auto end = chrono::high_resolution_clock::now();
- //cout << endl << (chrono::duration_cast<chrono::duration<double>>(end - start)).count();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement