結果
| 問題 |
No.620 ぐるぐるぐるりん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-20 21:01:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 1,000 ms |
| コード長 | 2,652 bytes |
| コンパイル時間 | 1,934 ms |
| コンパイル使用メモリ | 196,148 KB |
| 最終ジャッジ日時 | 2025-01-05 06:07:15 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << fixed << setprecision(30) << x << endl
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
os << "sz:" << v.size() << "\n[";
for (const auto& p : v) {
os << p << ",";
}
os << "]\n";
return os;
}
template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
os << "(" << p.first << "," << p.second
<< ")";
return os;
}
constexpr ld PI = static_cast<ld>(3.1415926535897932384626433832795);
constexpr ld EPS = static_cast<ld>(1e-8);
struct Vec {
Vec() : dx{0}, dy{0} {}
Vec(const ld dx, const ld dy) : dx{dx}, dy{dy} {}
ld dx;
ld dy;
Vec rotate(const ld theta) const
{
Vec ans;
ans.dx = cosl(theta) * dx - sinl(theta) * dy;
ans.dy = sinl(theta) * dx + cosl(theta) * dy;
return ans;
}
Vec operator*(const ld x) const
{
Vec ans = *this;
ans.dx *= x;
ans.dy *= x;
return ans;
}
ld norm() const
{
return hypotl(dx, dy);
}
void normalize()
{
const ld n = norm();
dx /= n;
dy /= n;
}
};
ostream& operator<<(ostream& os, const Vec& v)
{
os << "(" << v.dx << "," << v.dy << ")";
return os;
}
int main()
{
int N;
cin >> N;
for (int q = 0; q < N; q++) {
int T;
cin >> T;
long double p, omega, v, gx, gy;
cin >> p >> omega >> v >> gx >> gy;
const ld l = hypotl(omega, (ld)(1 + v));
const ld theta = arg(complex<ld>{(ld)(1 + v), omega});
Vec g{gx - powl(l, T) * cosl((ld)T * theta), gy - powl(l, T) * sinl((ld)T * theta)};
ld F = 0;
for (int i = 0; i < T; i++) {
if (l < 1) {
F += powl(l, 2 * T - 2 - 2 * i);
} else {
F += powl(l, 2 * i);
}
}
if (omega == 0 and v == -1) {
for (int i = 0; i < T; i++) {
if (i == T - 1) {
cout << fixed << setprecision(50) << gx << " " << gy << endl;
} else {
cout << fixed << setprecision(50) << 0 << " " << 0 << endl;
}
}
} else {
for (int i = 0; i < T; i++) {
const Vec v = g.rotate(theta * (ld)(i + 1 - T)) * (powl(l, T - 1 - i) / F);
cout << fixed << setprecision(50) << (long double)v.dx << " " << (long double)v.dy << endl;
}
}
}
return 0;
}