题解:P10314 [SHUPC 2024] 函数

· · 题解

这道题很简单,模拟就行了。

要注意: \cot x=\frac{1}{\tan x}。

#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;
int main() {
    int t;
    cin >> t;
    while (t--) {
        double x;
        cin >> x;
        printf("%.6lf\n", x - 0.5 + 1.0 * atan(1.0 / tan(pi * x)) / pi);
    }
}