[AtCoder] [經典競程 90 題] 018 - Statue of Chokudai(★3)

題目連結: https://atcoder.jp/contests/typical90/tasks/typical90_r
題目大意:
在 $x=0$ 的平面上有一個高度為 $L$ 的摩天輪,其轉一圈要花費 $T$ 時間,並且其轉速固定。在時間點 $0$ 的時候某車廂座標為 $(0, 0, 0)$、$\frac{T}{4}$ 時座標為 $(0, -\frac{L}{2}, \frac{L}{2})$、$\frac{T}{2}$ 時座標為 $(0, 0, L)$、$\frac{3T}{4}$ 時座標為 $(0, \frac{L}{2}, \frac{L}{2})$。
現在有一個「高橋直大像」位在$(X, Y, 0)$的地方。給定 $Q$ 筆詢問,請每次回答當坐了 $e_i$ 時間的摩天輪後與「高橋直大像」的仰角夾角為多少?
高中基礎三角函數代一代移一移就好了,不知道題解怎麼寫XD
#include <bits/stdc++.h>
using namespace std;
using llf = long double;
static constexpr llf PI = acos(-1);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	int T, L, X, Y, Q;
	cin >> T >> L >> X >> Y >> Q;
	while (Q--) {
		int e; cin >> e;
		llf ang =  static_cast<llf>(e) / T * 2 * PI + PI;
		llf y = L * sin(ang) / 2, z = L * (cos(ang) + 1) / 2 ;

		llf dx = X, dy = Y - y, dz = -z;
		llf dd = hypot(dx, dy, dz);
		llf theta = acos(dz / dd);
		cout << theta / PI * 180 - 90 << '\n';
	}
	return 0;
}

留言

這個網誌中的熱門文章

[NPSC] 2009初賽 E. 檸檬汽水傳說

[TIOJ] 1902. 「殿仁.王,不認識,誰啊?」,然後他就死了……

[AtCoder] [經典競程 90 題] 024 - Select +/- One(★2)