• 红神的火炬


    题目链接: http://exercise.acmcoder.com/online/online_judge_ques?ques_id=3337&konwledgeId=40

    解题思路: 把外面的线分成两个部分,直线的部分和曲线的部分,直线的部分刚好对于多边形的周长,曲线的部分正好是一个圆。n边型共有n个顶点,其中对于每个圆柱的顶点,内角和对应的外角和共180,所以所有的外角和是n*180-(n-2)*180=360。

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 
     4 typedef long long LL;
     5 const int MAXN=100005;
     6 const LL MOD7 = 1e9+7;
     7 
     8 int n;
     9 double R;
    10 double c[105][2];
    11 
    12 void solve()
    13 {
    14     double ans = 0;
    15     for (int i=2;i<=n;++i)
    16     {
    17         ans += sqrt((c[i][0]-c[i-1][0]) * (c[i][0]-c[i-1][0]) + (c[i][1]-c[i-1][1])*(c[i][1]-c[i-1][1]));
    18     }
    19     ans+=sqrt((c[1][0]-c[n][0])*(c[1][0]-c[n][0]) + (c[1][1]-c[n][1])*(c[1][1]-c[n][1]));
    20     ans+=2*3.1415926*R;
    21     printf("%.2f
    ",ans);
    22 }
    23 int main()
    24 {
    25 #ifndef ONLINE_JUDGE
    26     freopen("test.txt","r",stdin);
    27 #endif // ONLINE_JUDGE
    28     scanf("%d%lf",&n,&R);
    29     for (int i=1;i<=n;++i) scanf("%lf%lf",&c[i][0],&c[i][1]);
    30     solve();
    31     return 0;
    32 }
  • 相关阅读:
    EXCEL自动导出HTML
    亡灵序曲超清
    支持国产动画-唐伯卿和曾小兰
    中国表情
    logging 日志
    datetime库运用
    hashlib 加密
    os2
    python json数据处理
    python操作redis
  • 原文地址:https://www.cnblogs.com/djingjing/p/8993082.html
Copyright © 2020-2023  润新知