题解:P10520 [XJTUPC2024] 榕树之心

· · 题解

大意

输两个数,为 x 和 y,依次输出 x^{\prime} 和 y^{\prime}。

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

按空格隔开。

思路

直接按题目模拟。

代码

#include<bits/stdc++.h>
using namespace std;
double x,y;
int main(){
    cin>>x>>y;
    double p=sqrt(3);//sqrt自带小数
    printf("%5lf",x/2.00000+y/2.00000);
    cout<<" ";//别忘了
    printf("%5lf",p/2.0000*x-p/2.0000*y);
    return 0;
}