CF Amr and Pins (数学)
1 second
256 megabytes
standard input
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 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 a single integer — minimum number of steps required to move the center of the circle to the destination point.
2 0 0 0 4
1
1 1 1 4 4
3
4 5 6 5 6
0
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).
把两个圆抽象成两个点,两个点的坐标是圆心,那么最短的距离就是这两点的距离,而每次能移动的最大距离是2R,所以每次先移动那么多,直到最后接近的时候,又从某个不同的点开始旋转。说实话我无法证明最后这个旋转一定能到达,但是凭着直觉就敲上去了,结果1A,运气吧。
#include <bits/stdc++.h>
using namespace std; int main(void)
{
double s,r;
double x_1,y_1,x_2,y_2;
int ans; scanf("%lf",&r);
scanf("%lf%lf%lf%lf",&x_1,&y_1,&x_2,&y_2);
s = sqrt(pow(x_1 - x_2,) + pow(y_1 - y_2,)); ans = s / ( * r);
if(ans * r * < s)
ans += ;
printf("%d\n",ans); return ;
}
CF Amr and Pins (数学)的更多相关文章
- CF 287(div 2) B Amr and Pins
解题思路:一开始自己想的是找出每一次旋转所得到的圆心轨迹,将想要旋转到的点代入该圆心轨迹的方程,如果相等,则跳出循环,如果不相等,则接着进行下一次旋转.后来看了题解,发现,它的旋转可以是任意角度的,所 ...
- 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 ...
- Codefores 507B 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 Music (贪心)
Amr and Music time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 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 - 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 507B. Amr and Pins 解题报告
题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...
- (简单) CF 44D Hyperdrive,数学。
In a far away galaxy there are n inhabited planets, numbered with numbers from 1 to n. They are loca ...
随机推荐
- https://github.com/mlzboy/spider-impl.git
Installation - pygit2 0.24.0 documentation Python 2.7, 3.2+ or PyPy 2.6+ (including the development ...
- work-10
0. 问题描述 见老师博客 1.架构简介 经过软件工程的课程,我将学到的很多知识应用到了这次作业中首先,我从架构上来讲解下我的这次作业. 由于各个语言优势不相同,例如在C++课上我们讲到了C++的尴尬 ...
- bitmap的实现方法
bitmap是一个十分有用的结构.所谓的Bit-map就是用一个bit位来标记某个元素对应的Value, 而Key即是该元素.由于采用了Bit为单位来存储数据,因此在存储空间方面,可以大大节省. 适用 ...
- 论DATASNAP中间件对象池
在此,笔者以DATASNAP为例,其它中间件以此类推. 中间件为什么要使用对象池? 对象池——让所有的对象免堕轮回之苦,对象不再为其生和死而烦恼. 要想让中间件长久稳定地运行,做到无人值守,对象池很重 ...
- TQMsgPack序列还原clientdataset.data
序列 procedure TForm1.Button2Click(Sender: TObject);var msgpack: TQMsgPack;begin msgpack := TQMsgPack. ...
- linux下的调试工具ltrace与strace
ltrace能够跟踪进程的库函数调用,它会显现出哪个库函数被调用,而strace则是跟踪程序的每个系统调用. 下面是一个ltrace与strace的对比 1)系统调用的输出对比 我们用输出he ...
- Spring Controller参数为空串的处理方式
控制器参数为String类型 Spring框架接收到传入的空串后,此参数被赋值为空串,不为null. 控制器参数为非String类型 Spring框架接收到传入的空串后,此参数被赋值为null.
- Docker基本命令
1.搜索Docker镜像 docker search <镜像名> 2.获取镜像 docker pull <镜像名> 3.查看本地镜像 docker images 4.删除镜像 ...
- 漫谈C#之关键字
每一种语言都有非常多的关键字,而且这些关键字也都大同小异,不过毕竟还是有些许的不一样.有些关键字大家碰到的多了,自然就熟悉了,但是有些关键字用得不大多,或者是新引入的,所以就不大熟悉了.我平常在用的时 ...
- SuperToolTips
https://github.com/nhaarman/supertooltips supertooltips-master.zip