Advertisement
limimage

AAAAAAAAAAAAAA

Apr 18th, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #define endl "\n"
  4. using namespace std;
  5. using ll = long long;
  6. using ld = long double;
  7. using pii = pair<int, int>;
  8.  
  9. constexpr int N = 1e5 + 5;
  10.  
  11. int t, w, h, u, l, r, d;
  12. ld ans = 0, answer = 0;
  13. ld deg[N];
  14.  
  15. void Solve(int id) {
  16. ans = 0;
  17. cin >> w >> h >> l >> u >> r >> d;
  18. ld cur = 1;
  19. if (h > d)
  20. for (int i = 1; i < l; i++) {
  21. ans += cur;
  22. cur /= 2;
  23. cur += cur * (d - 1) / i;
  24. }
  25. ans *= deg[d];
  26. answer = ans;
  27. ans = 0;
  28. cur = 1;
  29. if (w > r)
  30. for (int i = 1; i < u; i++) {
  31. ans += cur;
  32. cur /= 2;
  33. cur += cur * (r - 1) / i;
  34. }
  35. answer += ans * deg[r];
  36. if (r - l + 1 == w || d - u + 1 == h || l == 1 && u == 1)
  37. answer = 0;
  38. cout << "Case #" << id << ": " << fixed << setprecision(40) << answer << endl;
  39. }
  40.  
  41. int main() {
  42. ios::sync_with_stdio(false);
  43. cin.tie(nullptr);
  44. cout.tie(nullptr);
  45. deg[0] = 1;
  46. for (int i = 1; i < N; i++)
  47. deg[i] = deg[i - 1] / 2;
  48. cin >> t;
  49. for (int i = 1; i <= t; i++)
  50. //auto start = chrono::high_resolution_clock::now();
  51. Solve(i);
  52. //auto end = chrono::high_resolution_clock::now();
  53. //cout << endl << (chrono::duration_cast<chrono::duration<double>>(end - start)).count();
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement