Skip to content

Problem L: 死亡圣器

📝 题目描述

🔑 算法模块

提示

acos(-1)

M_PI

圆周率 23 位 3.14159265358979323846264

💡 思路分析

化简公式可得:\(S = r^2 \cdot (3\sqrt{3} - \pi)\)

🖥️ 代码实现

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <bits/stdc++.h>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T;
    std::cin >> T;
    std::cout << std::fixed << std::setprecision(2);
    while (T--) {
        double r;
        std::cin >> r;
        std::cout << r * r * (sqrt(3.0) * 3 - M_PI) << "\n";
    }
    return 0;
}

⏱️ 复杂度分析

📚 拓展