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 ...
随机推荐
- cf3D Least Cost Bracket Sequence
This is yet another problem on regular bracket sequences. A bracket sequence is called regular, if b ...
- eq=等于gt=大于lt=小于的英文全称
EQ: Equal GT: Greater Than LT: Less than 知道全称就不会忘记
- go初识
for循环 ; i < ; i++ { fmt.Println(i*i) } ls := "agd" for _, arg := range ls{ fmt.Println( ...
- 模拟用户登录-SpringMVC+Spring+Mybatis整合小案例
1. 导入相关jar包 ant-1.9.6.jarant-launcher-1.9.6.jaraopalliance.jarasm-5.1.jarasm-5.2.jaraspectj-weaver.j ...
- 使用icomoon把svg图片生成字体图标
今天看了使用icomoon来将svg转换成图标字体,本来是不会使用别人给的svg,也不清楚具体的好处是什么,查了svg以后,越来越懵,svg挺好的为什么要转成图标字体呢. 一.SVG介绍 SVG 是一 ...
- JS标签获取另一个页面传过来的href值
a href=b.html?id=楼主>B页面</a>b.html中的获取函数:function getParam(){C1=window.location.href.split(& ...
- 【mac】屏幕截图快捷键
这里只说四种 1.command+shift+4 截图是区域截图,会自动保存在桌面上 2.command+shift+control+4 区域截图,截图会自动保存在剪切板中,然后你可以通过comman ...
- 基于Lua插件化的Pcap流量监听代理
1.前言 我们在实际工作中,遇到了一个这样的用例,在每天例行扫描活动中,发现有些应用系统不定期的被扫挂,因为我们不是服务的制造者,没有办法在不同的系统里打印日志,所以我们就想用一个工具来获取特定服务的 ...
- 聊聊WiFi Hacks:为何你的Karma攻击不好使了
0.前言 三年前我发表了一篇文章<黑客有办法让你自动连上陌生WiFi>,介绍Karma攻击可以让你的无线设备自动连上黑客的WiFi.当时引起了还算比较热烈的讨论,关于WiFi安全,关于Ka ...
- Centos7配置Grafana对接OpenLDAP
在grafana的主配置文件grafana.ini中开启LDAP认证 注意:grafana有两个地方需要指定(/etc/grafana/grafana.ini和/usr/share/grafana/c ...