Codefores 507B 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).
画个图可发现到以圆的边界为转动中心,可以到达的新的圆的中心集也是一个圆。
且原点x , y 到点x' , y'的关系.
是sqrt ((x-x')^2 + (y-y')^2) ..与 2*R的距离有关的。
#include<bits/stdc++.h>
using namespace std;
int main()
{
double r , x0 , y0 , x1 , y1 ;
while( cin >> r >> x0 >> y0 >> x1 >> y1 ) {
r *= 2.0 ;
double a = fabs(x1-x0) / r , b = fabs(y1-y0) / r ;
double c = sqrt( a*a + b*b );
printf("%.0lf\n",ceil(c));
}
}
Codefores 507B Amr and Pins的更多相关文章
- 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 Amr and Pins (数学)
Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- 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 287(div 2) B Amr and Pins
解题思路:一开始自己想的是找出每一次旋转所得到的圆心轨迹,将想要旋转到的点代入该圆心轨迹的方程,如果相等,则跳出循环,如果不相等,则接着进行下一次旋转.后来看了题解,发现,它的旋转可以是任意角度的,所 ...
- CodeForces Round #287 Div.2
A. Amr and Music (贪心) 水题,没能秒切,略尴尬. #include <cstdio> #include <algorithm> using namespac ...
- ffmpeg常用转换命令,支持WAV转AMR
音频转换: 1.转换amr到mp3: ffmpeg -i shenhuxi.amr amr2mp3.mp3 2.转换amr到wav: ffmpeg -acodec libamr_nb -i shenh ...
随机推荐
- springboot的jar包部署
由于springboot常用war包部署,改为cloud开发模式多端口情况下,部署反而不习惯 毕竟,war包要不要项目名访问都必须放在tomcat的root目录下 而此目录限制只能放置一个项目,并且登 ...
- 从“中产梦”中醒来,好好打工吧
"中产"定义 自打"中产阶级/阶层"概念出现,总有人试图给出定义.搞不清何为"中产"却试图定义"中产阶级/阶层",注定是 ...
- RabbitMQ数据同步一致性解决方案
1.概述 我们知道在使用RabbitMQ时,生产者将消息发布出去之后,消息是否顺利到达broker代理服务器呢?默认情况下发布操作没有任何信息返回给生产者,也就是生产者是不知道消息有没有顺利到达bro ...
- python读取pcap包
import struct class FileConvert(object): ''' test python file''' def __init__(self): self.aa = 0 sel ...
- vue新建项目之饿了么组件标准配置
main.js import Vue from 'vue' import App from './App.vue' import ElementUI from 'element-ui'; import ...
- AGC003[BCDEF]题解
2018-12-28 有点累EF明天再写叭=v= 2018-12-29 update EF B - Simplified mahjong 可以注意到 一段连续的非0序列都可以凑出 就是显然%2=0的可 ...
- Python lambda 多变量
>> x = list(map(lambda x, y: (x>3, y>0), (1,2,3,4,5), (0,1,2,3,4)))>>> x[(False ...
- 【TCP】tcp协议通信中io
阻塞IO recv,接收数据,若没有,将阻塞, 当对方发数据来后,linux内核缓冲区得到数据, 内核数据复制到recv()调用所在的用户空间, 阻塞解除,进行下一步处理, 非阻塞IO 轮询调用rec ...
- inputAccessoryView,inputView
我们在使用UITextView和UITextField的时候,可以通过它们的inputAccessoryView属性给输入时呼出的键盘加一个附属视图,通常是UIToolBar,用于回收键盘. 但是当我 ...
- selenium问题之定位不到元素(NoSuchElementException)
在使用selenium+爬虫的时候,经常会遇到一个问题,就是NoSuchElementException,定位不到元素的问题 一,打开了新页面,一般selenium点击新链接跳转打开了一个新页面,那么 ...