zoukankan      html  css  js  c++  java
  • POJ2365【几何】

    因为给出的点已经是顺时针了,
    整个长度=相邻点距离+一个圆周长;
    C++ac代码…G++wa…因为标准不一样。G++用f

    //#include <bits/stdc++.h>
    #include<iostream>
    #include<math.h>
    #include<string.h>
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    const double pi=acos(double(-1));
    
    const int N=1e2+10;
    
    double x[N],y[N];
    
    int main()
    {
        int n;
        double r,len;
        while(~scanf("%d%lf",&n,&r))
        {
            len=0;
            for(int i=1;i<=n;i++)
            {
                scanf("%lf%lf",&x[i],&y[i]);
                if(i>=2)
                {
                    if(i!=n)
                        len+=sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
                    else
                    {
                        len+=sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
                        len+=sqrt((x[i]-x[1])*(x[i]-x[1])+(y[i]-y[1])*(y[i]-y[1]));
                    }
                }
            }
            len+=2*pi*r;
            printf("%.2lf
    ",len);
        }
        return 0;
    }
  • 相关阅读:
    python 线程同步
    python 线程模块
    Python线程
    Python 多线程
    Python SMTP发送邮件
    Python Internet 模块
    简单实例
    Socket 对象(内建)方法
    Python 网络编程
    python 数据库错误处理
  • 原文地址:https://www.cnblogs.com/keyboarder-zsq/p/5934863.html
Copyright © 2011-2022 走看看