简单题

poj2365_i++poj2365_#define_02View 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;
}