poj2365

简单题

View Code
#include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
#include
<cmath>
using namespace std;

#define pi acos(-1)

struct Point
{
double x, y;
}first, now, last;

int n;
double r;

double dist(Point &a, Point &b)
{
Point p;
p.x
= a.x - b.x;
p.y
= a.y - b.y;
return sqrt(p.x * p.x + p.y * p.y);
}

int main()
{
//freopen("t.txt", "r", stdin);
scanf("%d%lf", &n, &r);
double ans = pi * 2 * r;
scanf(
"%lf%lf", &first.x, &first.y);
last
= first;
for (int i = 1; i < n; i++)
{
scanf(
"%lf%lf", &now.x, &now.y);
ans
+= dist(now, last);
last
= now;
}
ans
+= dist(last, first);
printf(
"%.2f\n", ans);
return 0;
}
原文地址:https://www.cnblogs.com/rainydays/p/2124898.html