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\n",len);
    }
    return 0;
}
posted @ 2016-08-17 23:38  see_you_later  阅读(112)  评论(0编辑  收藏  举报