QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#16467#3008. Rocket Powered HovercraftQingyuAC ✓3ms4392kbC++201.7kb2021-12-19 23:53:052022-05-04 08:57:09

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 08:57:09]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:4392kb
  • [2021-12-19 23:53:05]
  • 提交

answer

// Problem         : Rocket Ship (NAIPC 2019)
// Author          : Darcy Best
// Expected Result : AC
// Complexity      : O(log(PRECISION))
 
// Once you know how long both rockets are activated, the other two are
// determinable

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

const double PI = acos(-1.0);
const double EPS = 1e-12;

double naive_answer; // Rotate first, then move
double x,y,w,v;      // Input
double r,R;          // Radii of the circles
double phi;

double sgn(double x){ return x < 0 ? -1 : 1; }

double g(double theta){
  double X = r * cos(theta - PI/2);
  double Y = r * sin(theta - PI/2) + r;

  if(hypot(X,Y) > R) return naive_answer; // bad!

  double a = abs(Y - r), b = abs(X);

  if(atan2(Y-r,X) > 0) a = -a;
  if(X < 0) b = -b;
  
  double tA = a*a*(R*R-Y*Y) + 2*a*b*X*Y + b*b*(R*R-X*X);
  double tB = a * X + b * Y;
  double tC = a*a + b*b;

  double t = max((-sqrt(tA) - tB) / tC,(sqrt(tA) - tB) / tC);

  double Xp = X + a*t, Yp = Y + b*t;

  double phi_p = atan2(Yp,Xp);
  if(phi_p < 0) phi_p += 2*PI;

  if(phi_p - phi > EPS) return naive_answer;

  return (phi - phi_p) / w + (hypot(Xp-X,Yp-Y) + r * theta) / v;
}

double f(double lo, double hi){
  double q1 = (2*lo + hi)/3, q2 = (lo + 2*hi)/3;
  double a = g(q1), b = g(q2);

  if(fabs(lo-hi) < EPS && fabs(a-b) < EPS) return (a+b)/2;
  return a > b ? f(q1,hi) : f(lo,q2);
}

int main(){
  cin >> x >> y >> v >> w;

  y = abs(y);
  r = v / w;
  R = hypot(x,y);
  phi = atan2(y,x);

  naive_answer = g(0);

  cout << fixed << setprecision(10) << min(f(0,PI/2),f(PI/2,PI)) << endl;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 4248kb

input:

45 179
0.94 3.34

output:

196.4571416878

result:

ok found '196.45714', expected '196.45714', error '0.00000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 4356kb

input:

365 243
1.55 0.15

output:

283.1207010009

result:

ok found '283.12070', expected '283.12070', error '0.00000'

Test #3:

score: 0
Accepted
time: 3ms
memory: 4388kb

input:

356 -176
0.18 0.71

output:

2206.2986086528

result:

ok found '2206.29861', expected '2206.29861', error '0.00000'

Test #4:

score: 0
Accepted
time: 3ms
memory: 4392kb

input:

326 -350
0.14 2.01

output:

3416.5110771656

result:

ok found '3416.51108', expected '3416.51108', error '0.00000'

Test #5:

score: 0
Accepted
time: 3ms
memory: 4324kb

input:

-360 -428
0.65 0.28

output:

864.9603835189

result:

ok found '864.96038', expected '864.96038', error '0.00000'

Test #6:

score: 0
Accepted
time: 3ms
memory: 4392kb

input:

-419 233
0.20 0.74

output:

2399.3423143047

result:

ok found '2399.34231', expected '2399.34231', error '0.00000'

Test #7:

score: 0
Accepted
time: 3ms
memory: 4236kb

input:

365 288
0.91 1.47

output:

510.9559101916

result:

ok found '510.95591', expected '510.95591', error '0.00000'

Test #8:

score: 0
Accepted
time: 3ms
memory: 4348kb

input:

-39 245
0.93 0.29

output:

269.2925950071

result:

ok found '269.29260', expected '269.29260', error '0.00000'

Test #9:

score: 0
Accepted
time: 3ms
memory: 4252kb

input:

66 461
2.17 0.32

output:

215.9964563815

result:

ok found '215.99646', expected '215.99646', error '0.00000'

Test #10:

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

input:

476 380
0.40 0.26

output:

1522.8868326091

result:

ok found '1522.88683', expected '1522.88683', error '0.00000'

Test #11:

score: 0
Accepted
time: 3ms
memory: 4232kb

input:

-459 -314
0.13 0.51

output:

4280.9215740274

result:

ok found '4280.92157', expected '4280.92157', error '0.00000'

Test #12:

score: 0
Accepted
time: 3ms
memory: 4388kb

input:

-38 -31
0.30 0.02

output:

244.0422809796

result:

ok found '244.04228', expected '244.04228', error '0.00000'

Test #13:

score: 0
Accepted
time: 3ms
memory: 4236kb

input:

-282 -57
0.50 0.01

output:

778.3327435529

result:

ok found '778.33274', expected '778.33274', error '0.00000'

Test #14:

score: 0
Accepted
time: 3ms
memory: 4252kb

input:

-261 -155
0.20 0.02

output:

1598.8862728257

result:

ok found '1598.88627', expected '1598.88627', error '0.00000'

Test #15:

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

input:

-135 47
0.68 0.01

output:

415.1412675016

result:

ok found '415.14127', expected '415.14127', error '0.00000'

Test #16:

score: 0
Accepted
time: 3ms
memory: 4184kb

input:

262 0
0.03 0.28

output:

8733.3333333333

result:

ok found '8733.33333', expected '8733.33333', error '0.00000'

Test #17:

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

input:

-10 10
1.00 0.10

output:

31.4159265359

result:

ok found '31.41593', expected '31.41593', error '0.00000'

Test #18:

score: 0
Accepted
time: 2ms
memory: 4184kb

input:

-20 0
1.00 0.10

output:

43.9724223676

result:

ok found '43.97242', expected '43.97242', error '0.00000'

Test #19:

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

input:

-18 112
1.00 0.10

output:

121.1797455767

result:

ok found '121.17975', expected '121.17975', error '0.00000'

Test #20:

score: 0
Accepted
time: 3ms
memory: 4392kb

input:

-18 112
0.10 10.00

output:

1134.4450922035

result:

ok found '1134.44509', expected '1134.44509', error '0.00000'

Test #21:

score: 0
Accepted
time: 3ms
memory: 4264kb

input:

-999 112
0.01 10.00

output:

100526.0703125447

result:

ok found '100526.07031', expected '100526.07031', error '0.00000'

Test #22:

score: 0
Accepted
time: 3ms
memory: 4356kb

input:

-999 112
10.00 0.01

output:

355.6584289993

result:

ok found '355.65843', expected '355.65843', error '0.00000'

Test #23:

score: 0
Accepted
time: 3ms
memory: 4280kb

input:

-1000 0
0.01 0.01

output:

100214.2092653631

result:

ok found '100214.20927', expected '100214.20927', error '0.00000'

Test #24:

score: 0
Accepted
time: 3ms
memory: 4340kb

input:

-1000 0
10.00 10.00

output:

100.2142092654

result:

ok found '100.21421', expected '100.21421', error '0.00000'

Test #25:

score: 0
Accepted
time: 1ms
memory: 4264kb

input:

-1 0
10.00 10.00

output:

0.3665191429

result:

ok found '0.36652', expected '0.36652', error '0.00000'

Test #26:

score: 0
Accepted
time: 3ms
memory: 4288kb

input:

-1 0
0.01 10.00

output:

100.2142092654

result:

ok found '100.21421', expected '100.21421', error '0.00000'

Test #27:

score: 0
Accepted
time: 3ms
memory: 4292kb

input:

-1 0
10.00 0.01

output:

314.2092653611

result:

ok found '314.20927', expected '314.20927', error '0.00000'

Test #28:

score: 0
Accepted
time: 3ms
memory: 4292kb

input:

1000 -1
10.00 0.01

output:

100.0000500166

result:

ok found '100.00005', expected '100.00005', error '0.00000'

Test #29:

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

input:

1000 -1
0.01 10.00

output:

100000.0499999875

result:

ok found '100000.05000', expected '100000.05000', error '0.00000'

Test #30:

score: 0
Accepted
time: 3ms
memory: 4280kb

input:

-862 -92
9.24 0.02

output:

209.2528658706

result:

ok found '209.25287', expected '209.25287', error '0.00000'

Test #31:

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

input:

-22 -8
0.24 0.02

output:

200.3014034502

result:

ok found '200.30140', expected '200.30140', error '0.00000'

Test #32:

score: 0
Accepted
time: 3ms
memory: 4248kb

input:

-574 -49
3.21 0.01

output:

413.7694710348

result:

ok found '413.76947', expected '413.76947', error '0.00000'

Test #33:

score: 0
Accepted
time: 3ms
memory: 4324kb

input:

-693 -228
7.62 0.02

output:

200.3083419730

result:

ok found '200.30834', expected '200.30834', error '0.00000'

Test #34:

score: 0
Accepted
time: 3ms
memory: 4184kb

input:

315 282
9.67 0.02

output:

59.1338985576

result:

ok found '59.13390', expected '59.13390', error '0.00000'