zoukankan      html  css  js  c++  java
  • Codeforce 507B

    Amr loves Geometry. One day he came up with a very interesting problem.

    Amr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y').

    In one step Amr can put a pin to the border of the circle in a certain point, then rotate the circle around that pin by any angle and finally remove the pin.

    Help Amr to achieve his goal in minimum number of steps.

    Input

    Input consists of 5 space-separated integers rxyxy' (1 ≤ r ≤ 105,  - 105 ≤ x, y, x', y' ≤ 105), circle radius, coordinates of original center of the circle and coordinates of destination center of the circle respectively.

    Output

    Output a single integer — minimum number of steps required to move the center of the circle to the destination point.

    Examples
    input
    2 0 0 0 4
    output
    1
    input
    1 1 1 4 4
    output
    3
    input
    4 5 6 5 6
    output
    0
    Note

    In the first sample test the optimal way is to put a pin at point (0, 2) and rotate the circle by 180 degrees counter-clockwise (or clockwise, no matter).

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <vector>
     6 #include <cstdlib>
     7 #include <iomanip>
     8 #include <cmath>
     9 #include <ctime>
    10 #include <map>
    11 #include <set>
    12 using namespace std;
    13 #define lowbit(x) (x&(-x))
    14 #define max(x,y) (x>y?x:y)
    15 #define min(x,y) (x<y?x:y)
    16 #define MAX 100000000000000000
    17 #define MOD 1000000007
    18 #define pi acos(-1.0)
    19 #define ei exp(1)
    20 #define PI 3.141592653589793238462
    21 #define INF 0x3f3f3f3f3f
    22 #define mem(a) (memset(a,0,sizeof(a)))
    23 typedef long long ll;
    24 ll gcd(ll a,ll b){
    25     return b?gcd(b,a%b):a;
    26 }
    27 bool cmp(int x,int y)
    28 {
    29     return x>y;
    30 }
    31 const int N=10005;
    32 const int mod=1e9+7;
    33 int a[256];
    34 int main()
    35 {
    36     std::ios::sync_with_stdio(false);
    37     double r,x,y,x1,y1;
    38     while(scanf("%lf%lf%lf%lf%lf",&r,&x,&y,&x1,&y1)!=EOF){
    39         double dis=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
    40         double d=2*r;
    41         int cnt=dis/d;
    42         if(cnt*d<dis)
    43             cnt++;
    44         printf("%d
    ",cnt);
    45     }
    46     return 0;
    47 }
  • 相关阅读:
    29Mybatis_整合ehcache以及应用场景
    28Mybatis_查询缓存-二级缓存-二级缓存测试-
    27Mybatis_一级缓存的实际应用场景
    解析分布式锁之Zookeeper实现(一)
    程序员的十年工作创业血泪史,万字长文,仔细读完,受益匪浅
    2018 Java线程热门面试题,你知道多少?
    看阿里P9架构师如何向你定义架构及架构师
    程序员30 岁之后:如何实现质的突破?
    强者自救,圣者渡人
    干货:通过双十一等项目实战看架构技术
  • 原文地址:https://www.cnblogs.com/wydxry/p/7269316.html
Copyright © 2011-2022 走看看