結果
| 問題 |
No.620 ぐるぐるぐるりん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-20 19:58:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,295 bytes |
| コンパイル時間 | 1,092 ms |
| コンパイル使用メモリ | 87,356 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 07:09:51 |
| 合計ジャッジ時間 | 4,996 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 17 |
ソースコード
#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();
}