Problem G. Glorious Stadium

AC代码(数学题从里向外画)

Select Code

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;

int main()
{
     freopen("glorious.in", "r", stdin);
     int t;
     int i, n;
     double r, k, s, s1, pi = 3.1415926;
     while(scanf("%d",&t)!=EOF)
     {
         for(int k1 = 1;k1<=t;k1++)
         {
             s = 0, s1 = 0;
             scanf("%d%lf%lf",&n,&r,&k);
             for(i = 0;i<n;i++)
             {
                 s1 = tan(pi/k)*r*r*k;
                 s = s+s1-pi*r*r;
                 r = r/cos(pi/k);
             }
             printf("Case %d: ", k1);
             printf("%.5lf\n",s);
         }
     }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41524782/article/details/81914037