結果

問題 No.620 ぐるぐるぐるりん
ユーザー pekempeypekempey
提出日時 2017-12-20 19:58:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,295 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 84,752 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-22 10:58:51
合計ジャッジ時間 4,692 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 53 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 52 ms
4,376 KB
testcase_30 AC 53 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <random>
#include <array>

using namespace std;

long double pi = acos(-1);

long double hypot2(long double x, long double y) {
  return x*x + y*y;
}

void solve() {
  int t;
  long double p, w, v, gx, gy;
  cin >> t >> p >> w >> v >> gx >> gy;

  long double D = hypot(1+v, w);
  long double gr = hypot(gx, gy);

  long double d = (gr - pow(D, t)) * (D - 1) / (pow(D, t) - 1);

  long double x = 1;
  long double y = 0;

  long double theta = fmod((atan2(w, 1 + v) + 2*pi) * t, 2*pi);
  long double phi = fmod(atan2(gy, gx) + 2*pi, 2*pi);


  long double dw;
  if (phi > theta) {
    if (phi - theta < 2*pi - (phi - theta)) {
      dw = phi - theta;
    } else {
      dw = -(2 * pi - (phi - theta));
    }
  } else {
    if (theta - phi < 2*pi - (theta - phi)) {
      dw = phi - theta;
    } else {
      dw = 2 * pi - (theta - phi);
    }
  }

  long double ok = 1e10;
  long double ng = 0;

  for (int ii = 0; ii < 500; ii++) {
    long double mid = (ok + ng) / 2;

    long double sum = 0;
    long double r = 1;
    for (int i = 0; i < t; i++) {
      r = r*D + d;
      sum += sqrt(mid / t) / r;
    }
    if (sum >= abs(dw)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  vector<long double> dx(t);
  vector<long double> dy(t);

  long double ww = 0;

  for (int i = 0; i < t; i++) {
    long double x0 = x;
    long double y0 = y;
    x = x0 * (1+v) - y0 * w;
    y = y0 * (1+v) + x0 * w;

    long double x2 = x;
    long double y2 = y;

    long double r = hypot(x, y);
    x += x / r * d;
    y += y / r * d;
    r += d;

    long double x1 = x;
    long double y1 = y;

    long double tmp = sqrt(ok / t) / r * (dw > 0 ? 1 : -1);
    ww += tmp;

    x = x1 * cos(tmp) - y1 * sin(tmp);
    y = x1 * sin(tmp) + y1 * cos(tmp);

    dx[i] = x - x2;
    dy[i] = y - y2;
  }

  x = 1;
  y = 0;

  long double s = 0;
  for (int i = 0; i < t; i++) {
    long double x0 = x;
    long double y0 = y;
    x = x0 * (v + 1) - w * y0 + dx[i];
    y = y0 * (v + 1) + w * x0 + dy[i];
    s += hypot2(dx[i], dy[i]);
  }

  fprintf(stderr, "P=%.30Lf\n", s);
  for (int i = 0; i < t; i++) {
    printf("%.30Lf %.30Lf\n", dx[i], dy[i]);
  }
}

int main() {
  int T;
  cin >> T;
  while (T--) solve();
}
0