跳到正文

题解

P10520 [XJTUPC2024] 榕树之心 tj

_colin1112_约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
获赞
1
题目
P10520

版本

  1. v1当前
  • 考察基本编程运算与语法。

思路

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

x′=12x+12yx^{\prime} = \frac{1}{2} x + \frac{1}{2} y y′=32x−32yy^{\prime} = \frac{\sqrt{3}}{2} x - \frac{\sqrt{3}}{2} y

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

Code

C++
#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;
}
原文