codeforcfes Codeforces Round #287 (Div. 2) B. 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).

题目分析:一个半径为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的更多相关文章
- 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 ...
- 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 ...
- 贪心 Codeforces Round #287 (Div. 2) A. Amr and Music
题目传送门 /* 贪心水题 */ #include <cstdio> #include <algorithm> #include <iostream> #inclu ...
- CodeForces Round #287 Div.2
A. Amr and Music (贪心) 水题,没能秒切,略尴尬. #include <cstdio> #include <algorithm> using namespac ...
- CF 287(div 2) B Amr and Pins
解题思路:一开始自己想的是找出每一次旋转所得到的圆心轨迹,将想要旋转到的点代入该圆心轨迹的方程,如果相等,则跳出循环,如果不相等,则接着进行下一次旋转.后来看了题解,发现,它的旋转可以是任意角度的,所 ...
- 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/ ...
- 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 ...
- 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 ...
- Codeforces Round #312 (Div. 2) C.Amr and Chemistry
Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experime ...
随机推荐
- Linux(6):定时任务
定时任务 定时任务的说明和分类 # 定时任务分类: 1. crond(crontab) 定时任务软件(软件包 cronie) 2. atd 运行一次 3. anacron 非7*24小时运行的服务器 ...
- CentOS7关于网络的设置
装好CentOS7后,我们一开始是上不了网的 这时候,可以输入命令dhclient,可以自动获取一个IP地址,再用命令ip addr查看IP 不过这时候获取的IP是动态的,下次重启系统后,IP地址也会 ...
- SHUoj 神无月排位赛
神无月排位赛 发布时间: 2017年7月8日 21:06 最后更新: 2017年7月8日 22:35 时间限制: 1000ms 内存限制: 128M 描述 <神无月>作为盛大游 ...
- ci框架——分页
1:在models里面写一个模型:page_model.php class Page_model extends CI_Model{ function page($tablename,$per_num ...
- webStorm汉化
http://www.sdbeta.com/xiazai/2015/0603/35070.html 注册时选择“License server”输入“http://idea.imsxm.com/”点击“ ...
- CCPC-Wannafly Winter Camp Day1 (Div2, online mirror) A,B,C,E,F,I,J
https://www.zhixincode.com/contest/7/problems A题 分类讨论 当B有点需要经过时 穿梭的花费肯定为2*k,也可以发现,我们要找到包含所有需要经过的点(不含 ...
- Paul Graham:梦寐以求的编程语言
我的朋友曾对一位著名的操作系统专家说他想要设计一种真正优秀的编程语言.那位专家回答,这是浪费时间,优秀的语言不一定会被市场接受,很可能无人使用,因为语言的流行不取决于它本身.至少,那位专家设计的语言就 ...
- Codeforces Round #321 (Div. 2) E
终于补好了. 题目链接: http://codeforces.com/contest/580/problem/E E. Kefa and Watch time limit per test 1 sec ...
- 精通python网络爬虫之自动爬取网页的爬虫 代码记录
items的编写 # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentati ...
- 《Java虚拟机原理图解》 1.2、class文件中的常量池
了解JVM虚拟机原理 是每一个Java程序员修炼的必经之路.但是由于JVM虚拟机中有很多的东西讲述的比较宽泛,在当前接触到的关于JVM虚拟机原理的教程或者博客中,绝大部分都是充斥的文字性的描述,很难给 ...