首页 > 其他分享 >ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest Problem G.

ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest Problem G.

时间:2023-04-24 23:04:21浏览次数:95  
标签:layer Contest int Programming long Collegiate stadium circle define


Problem G. Glorious Stadium
Input file: glorious.in
Output file: standard output
Balloon Color: Orange
A lot of people want to attend the World Cup, so we would like to construct a glorious stadium using the
following algorithm:
1. Construct 1st layer of the stadium by building a fence shaped like a regular polygon P1 with K
sides and its in-circle C1 (with radius R) is the field of the stadium.
2. Construct 2nd layer of the stadium by building a fence shaped like a regular polygon P2 with K
sides and its in-circle C2, such that C2 is the circumcircle of P1, so it surrounds the layer 1.
3. Construct 3rd layer of the stadium by building a fence shaped like a regular polygon P3 with K
sides and its in-circle C3, such that C3 is the circumcircle of P2, so it surrounds the layer 2.
Until · · ·
N. Construct n−th layer of the stadium by building a fence shaped like a regular polygon PN with K
sides and its in-circle CN , such that CN is the circumcircle of PN−1, so it surrounds the layer N −1.
For each layer of the stadium, the area of the polygon that is not included in its in-circle tells us the
amount of the people who can stay to cheer for the teams (because this is the only place they can sit).
We would like to calculate the sum of cheerers areas of all the N layers of the glorious stadium, that is:

N
i=1
Area(Pi \ Ci)
Page 9 of 16
ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest
Arab Academy for Science, Technology and Maritime Transport, 2017
Input
The first line of the input consists of a single integer 1 ≤ T ≤ 105
the number of test cases. Each test
case consists of one line containing 3 space separated integers N, R, K. N is the number of layers of
the stadium, R is the radius of the stadium C1 and K is the number of sides of the polygons; where
1 ≤ N ≤ 105
, 1 ≤ R ≤ 100, 3 ≤ K ≤ 2 · 104 and 5 · K ≥ N.
Output
For each test case output a single line displaying the case number and the area of the cheerers rounded
to exactly 5 decimal places. The output will be checked with a relative error.
Example
glorious.in standard output
3
3 10 3
2 10 4
5 100 6
Case 1: 4314.57552
Case 2: 257.52220
Case 3: 31096.23444
Note
• in-circle is the largest circle the will fit inside a polygon that touches every side.
• circumcircle is the circle that passes through each vertex of the regular polygon.
• The given figure is a demonstration of the first test case, where the radius of the smallest circle is
the given R, and the answer is the area of the grey parts.
• The formula P \ C denotes the area covered in P and not covered in C, as shown in the figure.

简单的计算几何题目;
推公式即可解决;

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef unsigned long long int ull;
#define maxn 100005
#define ms(x) memset(x,0,sizeof(x))
#define Inf 0x7fffffff
#define inf 0x3f3f3f3f
const int mod = 1e9 + 7;
#define pi acos(-1.0)
#define pii pair<int,int>
#define eps 1e-5
#define pll pair<ll,ll>
#define lson 2*x
#define rson 2*x+1

long long  qupower(int a, int b) {
    long long  ans = 1;
    while (b) {
        if (b & 1)ans = ans * a;
        b >>= 1;
        a = a * a;
    }
    return ans;
}

inline int read() {
    int an = 0, x = 1; char c = getchar();
    while (c > '9' || c < '0') {
        if (c == '-') {
            x = -1; 
        }
        c = getchar();
    }
    while (c >= '0'&&c <= '9') {
        an = an * 10 + c - '0'; c = getchar();
    }
    return an * x;
}


double  n,r,k;

double sum;




int main() {
//  ios::sync_with_stdio(false);
    freopen("glorious.in","r",stdin);
     int t;
    cin>>t;
    int cnt=0;
    while(t--){
        cnt++;
        cin>>n>>r>>k;
        sum=0.0;
        double R;   
        while(n--){
            double ans=0.0;
            R=1.0*r/(sin(pi*(k-2)/k/2));
            double a=2.0*sqrt(R*R-r*r);
            sum+=1.0*k/2*r*a-pi*r*r;
        //  cout<<sum<<endl;
            r=R*1.0;
        }
        cout<<"Case "<<cnt<<": ";
        printf("%.10f\n",1.0*sum);
    }
}


标签:layer,Contest,int,Programming,long,Collegiate,stadium,circle,define
From: https://blog.51cto.com/u_15657999/6221998

相关文章

  • ACM International Collegiate Programming Contest, Amman Collegiate Programming C
    Youaregivenan × mgrid,yourgoalistofindagroupoflinessuchthatthefollowingconditionsaremet:Notwolinesaretouching.Eachcellinthegridhasoneofitssidescoveredbyatleastonelineinthegroup.Alineisaborderofacellin......
  • Nordic Collegiate Programming Contest (NCPC) 2017 C 在线查询,更新
    Onehundredyearsfromnow,in2117,theInternationalCollegiateProgrammingContest(ofwhichtheNCPCisapart)hasexpandedsignificantlyanditisnowtheGalacticCollegiateProgrammingContest(GCPC).Thisyeartherearenteamsinthecontest.T......
  • The 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
    ThetunnelsofCuChiareanimmensenetworkofundergroundtunnelsconnectingroomslocatedintheCuChiDistrictofHoChiMinhCity.TheCuChitunnelswerethelocationofseveralmilitarycampaignsinthe1960s.Nowadays,itisapopulartouristdes......
  • ACM International Collegiate Programming Contest 2014 B SPFA 统计路径
    FloweryTrails!”()”*+,-).%”/)’0”122”1!2”342”522”!22”652”!42”72”72”5!2”!12”622”18!”162”!12”6”7”4”9”3”5”8”1”2”Inordertoattractmorevisitors,themanagerofanationalp......
  • ACM International Collegiate Programming Contest 2014 A dfs 好题
    GREAT+SWERC=PORTOWewanttohaveagreatSWERCatPortothisyearandweapproachedthischallengeinseveralways.Weevenframeditasawordadditionproblem,similartotheclassicSEND+MORE=MONEY,whereeachletterstandsforasingledigit(......
  • [CMU 15-418] (Lecture4) Parallel Programming Basics
    本系列文章为CMU15-418/15-618:ParallelComputerArchitectureandProgramming,Fall2018课程学习笔记课程官网:CMU15-418/15-618:ParallelComputerArchitectureandProgramming参考文章:CMU15-418notes相关资源与介绍:CMU15-418/StanfordCS149:ParallelComput......
  • AtCoder Beginner Contest 158
    AtCoderBeginnerContest158https://atcoder.jp/contests/abc158基础不牢,地动山摇D-StringFormation一个小小的STL应用#include<bits/stdc++.h>#definelllonglongusingnamespacestd;strings;intq,t,f;charc;intmain(){cin>>s>>q......
  • AtCoder Regular Contest 111 F Do you like query problems?
    洛谷传送门AtCoder传送门挺有意思的计数。计数感觉很难做,不妨转成期望,期望又可以转成概率之和。考虑枚举\(w\in[0,m-1]\),把\(>w\)的数设为\(1\),\(\lew\)的数设为\(0\)。那么期望就是所有\(w\),\(a_i\)为\(1\)的概率之和。对于一个\(i\),只有以下的操作能改变\(......
  • SMU Spring 2023 Trial Contest Round 9
    SMUSpring2023TrialContestRound9A-WrongSubtraction#include<bits/stdc++.h>usingnamespacestd;typedefpair<int,int>PII;typedefpair<string,int>PSI;constintN=1e5+5,INF=0x3f3f3f3f,Mod=1e6;constdoubleeps=1e-6;typedefl......
  • SMU Spring 2023 Trial Contest Round 9
    A.WrongSubtraction#include<bits/stdc++.h>usingnamespacestd;int32_tmain(){intn,k;cin>>n>>k;while(k--){if(n%10==0)n/=10;elsen--;}cout<<n;return0;}B.T......