B. Amr and Pins
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 r, x, y, x' y' (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.

Sample test(s)
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).

题目分析:一个半径为r,圆心在(x, y)处的圆,在圆的轮廓上上随意找一点作为数轴旋转移动该圆,问至少要经过多少次移动,才可以到达指定的圆心(x', y')。

注意一下数据类型的溢出问题。计算两个圆心之间的距离,取 dis/(r*2)的上限整数就可以了。比如如果结果=3.5,那就输出4.

代码如下:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h> using namespace std;
double r;
double dis(double x, double y, double a, double b)
{
return sqrt( ((x-a)*(x-a)+(y-b)*(y-b))/(r*r*4.0) );
} int main()
{ double x, y;
double a, b;
double dd;
scanf("%lf %lf %lf %lf %lf", &r, &x, &y, &a, &b);
dd=dis(x, y, a, b); int ff=(int)ceil(dd);
printf("%d\n", ff );
return 0;
}

codeforcfes Codeforces Round #287 (Div. 2) B. Amr and Pins的更多相关文章

  1. Codeforces Round #287 (Div. 2) B. Amr and Pins 水题

    B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  2. Codeforces Round #287 (Div. 2) A. Amr and Music 水题

    A. Amr and Music time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  3. 贪心 Codeforces Round #287 (Div. 2) A. Amr and Music

    题目传送门 /* 贪心水题 */ #include <cstdio> #include <algorithm> #include <iostream> #inclu ...

  4. CodeForces Round #287 Div.2

    A. Amr and Music (贪心) 水题,没能秒切,略尴尬. #include <cstdio> #include <algorithm> using namespac ...

  5. CF 287(div 2) B Amr and Pins

    解题思路:一开始自己想的是找出每一次旋转所得到的圆心轨迹,将想要旋转到的点代入该圆心轨迹的方程,如果相等,则跳出循环,如果不相等,则接着进行下一次旋转.后来看了题解,发现,它的旋转可以是任意角度的,所 ...

  6. Codeforces Round #312 (Div. 2) C. Amr and Chemistry 暴力

    C. Amr and Chemistry Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/558/ ...

  7. Codeforces Round #312 (Div. 2)B. Amr and The Large Array 暴力

    B. Amr and The Large Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

  8. Codeforces Round #287 (Div. 2) C. Guess Your Way Out! 思路

    C. Guess Your Way Out! time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. Codeforces Round #312 (Div. 2) C.Amr and Chemistry

    Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experime ...

随机推荐

  1. poj1717 Dominoes (背包)

    A domino is a flat, thumbsized tile, the face of which is divided into two squares, each left blank ...

  2. NAND FLASH 物理结构分析

    转自:http://blog.51cto.com/hardywang/2053915 NAND Flash是一种非易失性随机访问存储介质,基于浮栅(Floating Gate)晶体管设计,通过浮栅来锁 ...

  3. System.out.println()和System.out.write()的区别

    这两个函数一个是System.out.write()输出字符流,System.out.println()是输出字节流,很简单.看下面这个程序就明白了.     //import java.util.* ...

  4. PHP文件上传设置和处理(单文件)

    <!--upload.php内容--><?php /* 修改php.ini的设置 file_uploads必须是On upload_max_filesize 设置上传文件的大小,此值 ...

  5. 洛谷 [P2594] 染色游戏

    博弈论+SG函数的应用 这是一个二维翻硬币问题 一维翻硬币问题有一个结论: 局面的SG值等于局面中所有反面朝上的硬币单独存在时的SG值的异或和 这个结论同样适用于二维的翻硬币问题 证明可以用数学归纳法 ...

  6. [OS X实用技巧]机器人应用:一键将图片转换为PNG/JPEG/TIFF

    转自:http://www.maczhi.com/archives/2842.html 按教程老出错....试验了后使用: - 取得指定Finder对象,其它不变,但运行后不会出错. OS X实用技巧 ...

  7. cannot find package "golang.org/x/crypto/pbkdf2" in any of:

    cannot find package "golang.org/x/crypto/pbkdf2" in any of: /Users/zhou/go/src/mos.market/ ...

  8. bootstrap theme & template

    https://wrapbootstrap.com/ Unify http://wrapbootstrap.com/preview/WB0412697 https://htmlstream.com/p ...

  9. android连数据库

    package com.rockcheck.mes; import android.os.AsyncTask; import android.support.v7.app.AppCompatActiv ...

  10. 感受lambda之美,推荐收藏,需要时查阅

    一.引言二.java重要的函数式接口1.什么是函数式接口1.1 java8自带的常用函数式接口.1.2 惰性求值与及早求值2.常用的流2.1 collect(Collectors.toList())2 ...