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 题目意思:给出一个序列,然后找出出现次数最多,但区间占用长度最短的区间左右值. 由于是边读入边比 ...
随机推荐
- laravel基础课程---7、文件处理、闪存、cookie(cookie原理和使用场景)
laravel基础课程---7.文件处理.闪存.cookie(cookie原理和使用场景) 一.总结 一句话总结: 页面请求服务器的时候是把这个页面中所有的cookie都带上了的,cookie里面也存 ...
- linux进程学习笔记
学习了linux下的进程,觉得应该整理一下,忘得差不多了,顺便回顾一下. 学而时习之,不亦说乎~~ 进程笔记 ,什么是进程? The Single UNIX Specification, Versio ...
- codevs 4939 欧拉函数
传送门 4939 欧拉函数 时间限制: 1 s 空间限制: 1000 KB 题目等级 : 钻石 Diamon 题目描述 Description 输入一个数n,输出小于n且与n互素的整数个 ...
- 【Lintcode】018.Subsets II
题目: Given a list of numbers that may has duplicate numbers, return all possible subsets Notice Each ...
- docker安装与操作
准备和安装 1.到这个路径下下载docker engine: https://get.docker.com/rpm/1.7.1/centos-7/RPMS/x86_64/docker-engine-1 ...
- wxPython学习资料
[译]wxPython布局管理简介 https://www.pystack.org/wxpython_sizer/ 设计器.代码分离 http://book.douban.com/review/578 ...
- Scala学习——操作符(初)
经常看到却反应不出来的(->) val a = 2 val b = a->4 //表示生成一个tuple println(b._1+" "b._2) //2 4
- Scala学习——可变参数(初)
Scala 通过在参数的类型之后放一个星号来设置可变参数(可重复的参数) object Test { def main(args: Array[String]) { printStrings(&quo ...
- win7 64位搭建Mantis 缺陷管理系统
什么是Mantis MantisBT is a free popular web-based bugtracking system (feature list). It is written in t ...
- C#窗体上绘制矩形
先上效果图 鼠标三个事件 private void Form1_MouseDown(object sender, MouseEventArgs e) { //记录开始点 this.mousedown ...