QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#270819#5151. Bottle Flipckiseki#AC ✓0ms3976kbC++201.2kb2023-12-01 15:20:082023-12-01 15:20:08

Judging History

你现在查看的是最新测评结果

  • [2023-12-01 15:20:08]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3976kb
  • [2023-12-01 15:20:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
#include <experimental/iterator>
void debug_(auto s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

using llf = long double;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int h, r, dx, dy;
  cin >> h >> r >> dx >> dy;

  auto calc = [&](llf y) {
    llf M1 = y * dy; // * pi * r^2
    llf M2 = (h - y) * dx; // * pi * r^2
    llf p1 = y / 2;
    llf p2 = y + (h - y) / 2;
    return (p1 * M1 + p2 * M2) / (M1 + M2);
  };

  llf L = 0, R = h;
  for (int iter = 0; iter < 200; ++iter) {
    llf M1 = L + (R - L) / 3, M2 = R - (R - L) / 3;;
    if (calc(M1) < calc(M2)) R = M2;
    else L = M1; 
  }
  cout << fixed << setprecision(20) << L << '\n';
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3932kb

input:

22 4 1 4

output:

7.33333333309964518132

result:

ok found '7.3333333', expected '7.3333333', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3932kb

input:

7 2 655 988

output:

3.14159417146814026614

result:

ok found '3.1415942', expected '3.1415942', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

1 1 1 2

output:

0.41421356263463878476

result:

ok found '0.4142136', expected '0.4142136', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

1000 1000 999 1000

output:

499.87494468535237868156

result:

ok found '499.8749447', expected '499.8749375', error '0.0000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

1000 1000 1 1000

output:

30.65343003728877905104

result:

ok found '30.6534300', expected '30.6534300', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

1 1000 1 1000

output:

0.03065343003675762267

result:

ok found '0.0306534', expected '0.0306534', error '0.0000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3932kb

input:

1000 1000 482 483

output:

499.74093418917770731413

result:

ok found '499.7409342', expected '499.7409326', error '0.0000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

1 1000 482 483

output:

0.49974093507548498136

result:

ok found '0.4997409', expected '0.4997409', error '0.0000000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3976kb

input:

1 1000 1 2

output:

0.41421356263463878476

result:

ok found '0.4142136', expected '0.4142136', error '0.0000000'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

1000 1000 1 2

output:

414.21356255653983763354

result:

ok found '414.2135626', expected '414.2135624', error '0.0000000'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

961 1000 979 983

output:

480.01019321773953682508

result:

ok found '480.0101932', expected '480.0101932', error '0.0000000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

997 1000 977 983

output:

497.73698974100727460135

result:

ok found '497.7369897', expected '497.7369880', error '0.0000000'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

1 928 1 66

output:

0.10960059086198080906

result:

ok found '0.1096006', expected '0.1096006', error '0.0000000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

1 928 2 88

output:

0.13100580424613444634

result:

ok found '0.1310058', expected '0.1310058', error '0.0000000'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3976kb

input:

1 928 3 74

output:

0.16760090742551486033

result:

ok found '0.1676009', expected '0.1676009', error '0.0000000'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

1 928 3 41

output:

0.21290885545082767888

result:

ok found '0.2129089', expected '0.2129089', error '0.0000000'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

1 928 1 12

output:

0.22400923782705349305

result:

ok found '0.2240092', expected '0.2240092', error '0.0000000'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

2 928 89 93

output:

0.98900966007145781761

result:

ok found '0.9890097', expected '0.9890097', error '0.0000000'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

7 928 51 72

output:

3.19900987863144244507

result:

ok found '3.1990099', expected '3.1990099', error '0.0000000'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

722 547 709 752

output:

355.68639201604227531583

result:

ok found '355.6863920', expected '355.6863918', error '0.0000000'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

242 742 518 920

output:

103.74290347702104454763

result:

ok found '103.7429035', expected '103.7429035', error '0.0000000'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

873 701 43 201

output:

276.08755587926388982978

result:

ok found '276.0875559', expected '276.0875558', error '0.0000000'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

268 228 527 562

output:

131.84609209566263528235

result:

ok found '131.8460921', expected '131.8460919', error '0.0000000'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

312 558 341 839

output:

121.46838511264131071909

result:

ok found '121.4683851', expected '121.4683851', error '0.0000000'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

274 85 178 364

output:

112.75649076149763768567

result:

ok found '112.7564908', expected '112.7564907', error '0.0000000'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

641 539 341 977

output:

238.05443888742951610848

result:

ok found '238.0544389', expected '238.0544387', error '0.0000000'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

245 861 438 872

output:

101.61838398141908522410

result:

ok found '101.6183840', expected '101.6183839', error '0.0000000'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

640 181 156 606

output:

215.41983498342914585266

result:

ok found '215.4198350', expected '215.4198349', error '0.0000000'