P10520 [XJTUPC2024] 榕树之心 tj

· · 题解

思路

首先输入两个数 x,y,然后根据题面所给公式计算:

x^{\prime} = \frac{1}{2} x + \frac{1}{2} y y^{\prime} = \frac{\sqrt{3}}{2} x - \frac{\sqrt{3}}{2} y

依次输出算出的 x^{\prime} 与 y^{\prime} 即可。

Code

#include <bits/stdc++.h>
#define endl '\n'
#define ll long long

using namespace std;
const int E = 1e6 + 5;
ll x, y;
int main()
{
    cin >> x >> y;
    double x_1 = x * 1.0 / 2 + y * 1.0 / 2, y_1 = sqrt(3) * 1.0 / 2 * 1.0 * x - sqrt(3) * 1.0 / 2 * 1.0 * y;
    cout << fixed << setprecision(6) << x_1 << " " << y_1;
    return 0;
}