CodeForces - 507B - Amr and Pins(计算几何)
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.
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).
题解:每次我们可以看出圆心其实是移动直径的距离,然后如果两个位置之间的距离/直径的距离,然后向上取整就可以
注意x1,y1,x,y都是double型,不然会WA
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double r,x,y,x1,y1;
cin>>r>>x>>y>>x1>>y1;
long double s1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
long long int m=sqrt(s1)*1.0/(2*r);
double k=sqrt(s1)*1.0/(2*r);
//cout<<m<<" "<<k<<endl;
if(k>m)
{
cout<<m+1<<endl;
}
else
{
cout<<m<<endl;
}
return 0;
}
CodeForces - 507B - Amr and Pins(计算几何)的更多相关文章
- codeforces 507B. Amr and Pins 解题报告
题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...
- Codefores 507B Amr and Pins
B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforce 507B - Amr and Pins
Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r ...
- 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 ...
- codeforcfes 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 ...
- CF Amr and Pins (数学)
Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- CF 287(div 2) B Amr and Pins
解题思路:一开始自己想的是找出每一次旋转所得到的圆心轨迹,将想要旋转到的点代入该圆心轨迹的方程,如果相等,则跳出循环,如果不相等,则接着进行下一次旋转.后来看了题解,发现,它的旋转可以是任意角度的,所 ...
- 暴力 + 贪心 --- Codeforces 558C : Amr and Chemistry
C. Amr and Chemistry Problem's Link: http://codeforces.com/problemset/problem/558/C Mean: 给出n个数,让你通过 ...
- codeforces 558B. Amr and The Large Array 解题报告
题目链接:http://codeforces.com/problemset/problem/558/B 题目意思:给出一个序列,然后找出出现次数最多,但区间占用长度最短的区间左右值. 由于是边读入边比 ...
随机推荐
- BZOJ 2019 [Usaco2009 Nov]找工作:spfa【最长路】【判正环】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2019 题意: 奶牛们没钱了,正在找工作.农夫约翰知道后,希望奶牛们四处转转,碰碰运气. 而 ...
- 写个sleep玩玩
static void sig_when_weakup(int no){ printf("weakup weakup\n"); longjmp(buf, ); } void wea ...
- Sox语音转换的相关知识
SoX-linux 里操作音频的瑞士军刀 Sox是最为著名的Open Source声音文件 格式转换工具.已经被广泛移植到Dos.windows.OS2.Sun.Next.Unix.Linux等多个操 ...
- 《HTTP2基础教程》笔记
<HTTP2基础教程>笔记 HTTP/1问题 队头阻塞 低效TCP 慢启动 拥塞避免阶段 臃肿头部 受限的优先级 高优先级无法插队 第三方资源 h2也无法很好解决 web性能优化 DNS查 ...
- poj1065 Wooden Sticks[LIS or 贪心]
地址戳这.N根木棍待处理,每根有个长x宽y,处理第一根花费1代价,之后当处理到的后一根比前一根长或者宽要大时都要重新花费1代价,否则不花费.求最小花费代价.多组数据,N<=5000 本来是奔着贪 ...
- 洛谷 P2919 [USACO08NOV]守护农场Guarding the Farm
题目描述 The farm has many hills upon which Farmer John would like to place guards to ensure the safety ...
- 【C++基础】重载,覆盖,隐藏
函数签名的概念 函数签名主要包括1.函数名:2.参数列表(参数的个数.数据类型和顺序):但是注意,C++官方定义中函数签名不包括返回值!! 1.重载 函数重载是指在同一作用域内,可以有一组具有相同函数 ...
- 第十二章: 部署Django
本章包含创建一个django程序最必不可少的步骤 在服务器上部署它 如果你一直跟着我们的例子做,你可能正在用runserver 但是runserver 要部署你的django程序,你需要挂接到工业用的 ...
- Modbus通讯协议学习 - 认识篇
转自:http://www.cnblogs.com/luomingui/archive/2013/06/14/Modbus.html 什么是Modbus? Modbus 协议是应用于电子控制器上的一种 ...
- 基于Qt Gui的Led控制显示程序
基于arm + linux的嵌入式软件开发,基本上的内容主要是:u-boot的移植,kernel的裁剪和相关驱动程序的设计,root-fs的制作,应用程序的设计,其中,应用程序主要包含两方面的内容:G ...