LightOj-1022-Circle in Square


題目傳送門


題意:給定一個圓的半徑,求這個圓的外切正方形的面積與這個圓的面積差。

思路:面積差爲4*r*r-PI*r*r

#include <bits/stdc++.h>

using namespace std;

const double PI = 2*acos(0.0);
int main(void)
{
    int T, cas=1;
    scanf("%d", &T);
    while (T--)
    {
        double r;
        scanf("%lf", &r);
        printf("Case %d: %.2f\n", cas++, r*r*(4-PI));
    }
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章