ural 1020. Rope(几何)

题目链接:ural 1020. Rope

题目大意:按照顺序给定N个点,每个点有半径R,问说用线环绕N个点所需要的长度。

解题思路:因为需要围成一个圈,所以旋转角度一定是一周,板径又都相同,所以直接就是两两点之间的距离加上一个周长。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
const int maxn = 105;
const double pi = 4 * atan(1.0);

int N;
double R, x[maxn], y[maxn];

double dis (double x, double y) {
    return sqrt(x * x + y * y);
}

int main () {
    while (scanf("%d%lf", &N, &R) == 2) {
        for (int i = 0; i < N; i++)
            scanf("%lf%lf", &x[i], &y[i]);
        x[N] = x[0], y[N] = y[0];
        double ans = 2 * pi * R;
        for (int i = 0; i < N; i++)
            ans += dis(x[i]-x[i+1], y[i]-y[i+1]);
        printf("%.2lf\n", ans);
    }
    return 0;
}
时间: 2024-10-08 09:35:10

ural 1020. Rope(几何)的相关文章

URAL 1020 Rope

Java的类库还是能省点力气的…… 1 import java.awt.geom.Point2D; 2 import java.util.Scanner; 3 4 public class P1020 5 { 6 public static void main(String args[]) 7 { 8 try (Scanner cin = new Scanner(System.in)) 9 { 10 while (cin.hasNext()) 11 { 12 int n = cin.nextIn

URAL 1145. Rope in the Labyrinth(两次BFS啊 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1145 1145. Rope in the Labyrinth Time limit: 0.5 second Memory limit: 64 MB A labyrinth with rectangular form and size m × n is divided into square cells with sides' length 1 by lines that are paralle

ural 1145. Rope in the Labyrinth

1145. Rope in the Labyrinth Time limit: 0.5 secondMemory limit: 64 MB A labyrinth with rectangular form and size m × n is divided into square cells with sides' length 1 by lines that are parallel with the labyrinth's sides. Each cell of the grid is e

ural 1145 Rope in the Labyrinth 图中 bfs求树的直径

1145. Rope in the Labyrinth Time limit: 0.5 second Memory limit: 64 MB A labyrinth with rectangular form and size m × n is divided into square cells with sides' length 1 by lines that are parallel with the labyrinth's sides. Each cell of the grid is

URAL - 1963(几何)

不知道是不是几何题,反正就是找对称,值得注意的是,对称轴不一定过点,还可能在边上 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; const double mm=1e-7; double x[10],y[10]; bool deng(double a,double

URAL - 1793 Tray 2(几何题)

Tray 2 Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status Description One of the organizers of the Ural Regional School Programming Contest came to the university cafeteria to have lunch. He took a soup and a ma

URAL 1294. Mars Satellites 几何

1294. Mars Satellites Time limit: 1.0 second Memory limit: 64 MB Four artificial satellites travel in one plane along the areostationary orbit around Mars. They have code names A, B, C and D and travel exactly in this order. Venus's scouts for milita

hdu 1115 Lifting the Stone (数学几何)

Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5203    Accepted Submission(s): 2155 Problem Description There are many secret openings in the floor which are covered by a big

ural 1246. Tethered Dog

1246. Tethered Dog Time limit: 1.0 secondMemory limit: 64 MB A dog is tethered to a pole with a rope. The pole is located inside a fenced polygon (not necessarily convex) with nonzero area. The fence has no self-crosses. The Olympian runs along the f