結果

問題 No.620 ぐるぐるぐるりん
ユーザー pekempeypekempey
提出日時 2017-12-20 21:36:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 1,000 ms
コード長 1,637 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 93,836 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-03 21:28:45
合計ジャッジ時間 2,710 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using namespace std;

using P = complex<long double>;

long double det(long double a, long double b, long double c, long double d) {
  return a*d - b*c;
}

void solve() {
  int t;
  cin >> t;

  long double p, W, V, gx, gy;
  cin >> p >> W >> V >> gx >> gy;

  P g(gx, gy);
  P z(V + 1, W);

  // xi = real(z^{t-i})/2 u + imag(z^{t-i})/2 v
  // yi = -imag(z^{t-i})/2 u + real(z^{t-i})/2 v

  P zz = 1;

  long double A = 0;
  long double B = 0;
  long double C = 0;
  long double D = 0;

  for (int i = 0; i < t; i++) {
    A += real(zz) / 2 * real(zz);
    B += imag(zz) / 2 * real(zz);

    A += -imag(zz) / 2 * -imag(zz);
    B += real(zz) / 2 * -imag(zz);

    C += real(zz) / 2 * imag(zz);
    D += imag(zz) / 2 * imag(zz);

    C += -imag(zz) / 2 * real(zz);
    D += real(zz) / 2 * real(zz);
    zz *= z;
  }

  long double X = gx - real(zz);
  long double Y = gy - imag(zz);

  long double u = det(X, B, Y, D) / det(A, B, C, D);
  long double v = det(A, X, B, Y) / det(A, B, C, D);

  vector<long double> us(t);
  vector<long double> vs(t);
  zz = 1;
  for (int i = t - 1; i >= 0; i--) {
    us[i] = real(zz)/2 * u + imag(zz)/2 * v;
    vs[i] = -imag(zz)/2 * u + real(zz)/2 * v;
    zz *= z;
  }

  P a(1, 0);
  long double sum = 0;
  for (int i = 0; i < t; i++) {
    sum += norm(P(us[i], vs[i]));
    printf("%.30Lf %.30Lf\n", us[i], vs[i]);
    a = z*a + P(us[i], vs[i]);
  }
  cerr << a << endl;
  fprintf(stderr, "%.30Lf\n", sum);
}

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