QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#159413#7110. Kuririn MIRACLEucup-team180#AC ✓798ms237480kbC++141.8kb2023-09-02 17:54:212023-09-02 17:54:22

Judging History

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

  • [2023-09-02 17:54:22]
  • 评测
  • 测评结果:AC
  • 用时:798ms
  • 内存:237480kb
  • [2023-09-02 17:54:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int B = 30000000;
const double PI = acos(-1);
int main(){
  cout << fixed << setprecision(20);
  auto calc = [&](double x){
    return sqrt(1 + pow(sin(x), 2) / 3);
  };
  vector<double> sum(B + 1);
  sum[0] = 0;
  for (int i = 0; i < B; i++){
    double l = PI / B * i - PI;
    double m = PI / B * (i + 0.5) - PI;
    double r = PI / B * (i + 1) - PI;
    sum[i + 1] = sum[i] + (calc(l) + calc(m) * 4 + calc(r)) / 6 * (PI / B);
  }
  for (int i = 0; i <= B; i++){
    sum[i] /= sqrt(3);
    sum[i] += (cos(PI / B * i - PI) + 1) / 3;
  }
  auto intg = [&](double x){
    int cnt = floor((x + PI) / PI * B);
    double ans = sum[cnt];
    double l = PI / B * cnt - PI;
    double r = x;
    double m = (l + r) / 2;
    ans += (calc(l) + calc(m) * 4 + calc(r)) / 6 * (r - l);
    return ans;
  };
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    double v, r, d;
    cin >> v >> r >> d;
    double T0 = r * 2 / v * sum[B];
    if (d < T0 * v + 4 * r){
      cout << d / v << endl;
    } else {
      double tv = -PI / 2, fv = 0;
      for (int j = 0; j < 100; j++){
        double mid = (tv + fv) / 2;
        double theta = mid;
        double t = r * 2 / v * intg(mid);
        double x = r * 2 + v * t + r * 2 * cos(theta);
        double y = r * 2 * sin(theta);
        double phi = atan2(-y, d - x);
        double b = r * 4 * cos(theta) * (v * 2 * cos(phi) - v) + 8 * r * v * sin(theta) * sin(phi);
        if (b < 0){
          tv = mid;
        } else {
          fv = mid;
        }
      }
      double theta = tv;
      double t = r * 2 / v * intg(theta);
      double x = r * 2 + v * t + r * 2 * cos(theta);
      double y = r * 2 * sin(theta);
      double ans = t + hypot(d - x, y) / (v * 2);
      cout << ans << endl;
    }
  }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 740ms
memory: 237420kb

input:

1
2.00 3 30.0

output:

8.31057996281596977894

result:

ok found '8.3105800', expected '8.3105799', error '0.0000000'

Test #2:

score: 0
Accepted
time: 746ms
memory: 237480kb

input:

100
8.66 6.05 71.59
8.44 8.67 82.55
4.23 9.68 24.74
6.63 9.95 7.45
1.2 7.27 97.55
2.08 2.94 31.61
8.48 5.56 20.16
7.35 5.55 52.48
1.35 8.15 51.23
3.88 9.02 72.37
7.03 1.97 57.03
1.78 4.44 93.44
5.5 6.11 52.94
1.09 9.64 69.01
1.01 3.54 16.78
1.63 4.55 44.06
5.82 5.51 5.92
5.62 2.93 76.01
4.75 4.43 73...

output:

4.45783712799601428145
5.48836084875994600907
5.84869976359337950811
1.12368024132730015552
43.26648005550209319381
8.30549016395050010431
2.37735849056603765206
4.01548600050246928816
37.94814814814814241117
18.65206185567010521709
4.15512364383744703389
27.17896301269641412546
9.625454545454545041...

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 798ms
memory: 237344kb

input:

1000
7.52 6.68 80.67
5.34 6.82 45.75
3.57 6.35 22.35
9.55 3.65 31.38
9.37 5.73 40.42
1.83 8.38 82.97
4.86 6.13 9.45
3.88 5.34 84.19
6.49 4.15 85.24
6.51 7.23 42.97
3.0 5.98 57.53
9.35 2.76 69.07
6.76 9.16 91.24
2.98 9.89 49.2
9.16 3.85 66.14
1.84 3.03 37.43
8.01 5.04 50.98
4.05 9.86 4.76
5.4 5.49 60...

output:

5.77088265698497693279
8.56741573033707837226
6.26050420168067311977
3.28586387434554927367
4.31376734258271099520
25.17648422198339375200
1.94444444444444419773
11.40629961692981453325
6.80719121539954308275
6.60061443932411684443
10.72771261154767508117
3.80019784732525023330
7.4844843228940618473...

result:

ok 1000 numbers

Extra Test:

score: 0
Extra Test Passed