codeforces 507B. Amr and Pins 解题报告
题目链接:http://codeforces.com/problemset/problem/507/B
题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置。问最少步数是多少。移动见下图。(通过圆上的边固定转动点,然后转动任意位置,圆心就会移动了,这个还是直接看图吧)

解题的思路就是,两点之间,距离最短啦~~~~要想得到最少步数,我们需要保证圆心在这条连线上移动,每次转动的角度是180度,而每步移动的距离是2r,直到两个圆交叉,要注意最后一步转动的角度可能会小于180度。最后就是注意精度啦,用天花板函数ceil()吧,否则精度会被舍弃,最后一步实质上根本没有算进去!~~~~更详细的解题思路请参考官方题解。
http://codeforces.com/blog/entry/15975
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std; typedef __int64 ll; int main()
{
ll r, x, y, x1, y1;
while (cin >> r >> x >> y >> x1 >> y1) {
ll difx = (x-x1)*(x-x1);
ll dify = (y-y1)*(y-y1);
ll ans = ceil(sqrt(difx + dify) / (*r));
printf("%I64d\n", ans);
}
return ;
}
codeforces 507B. Amr and Pins 解题报告的更多相关文章
- 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 Educational Round 92 赛后解题报告(A-G)
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...
- codeforces 476C.Dreamoon and Sums 解题报告
题目链接:http://codeforces.com/problemset/problem/476/C 题目意思:给出两个数:a 和 b,要求算出 (x/b) / (x%b) == k,其中 k 的取 ...
- Codeforces Round #382 (Div. 2) 解题报告
CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...
- Codefores 507B Amr and Pins
B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- codeforces 500B.New Year Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...
- codeforces B. Xenia and Ringroad 解题报告
题目链接:http://codeforces.com/problemset/problem/339/B 题目理解不难,这句是解题的关键 In order to complete the i-th ta ...
- codeforces 462C Appleman and Toastman 解题报告
题目链接:http://codeforces.com/problemset/problem/461/A 题目意思:给出一群由 n 个数组成的集合你,依次循环执行两种操作: (1)每次Toastman得 ...
- codeforces 460A Vasya and Socks 解题报告
题目链接:http://codeforces.com/problemset/problem/460/A 题目意思:有一个人有 n 对袜子,每天早上会穿一对,然后当天的晚上就会扔掉,不过他会在 m 的倍 ...
随机推荐
- codeforces #270 ABCD
Codeforces Round #270 A - Design Tutorial: Learn from Math 题意:给出n,求出两个合数x和y使x+y=n. 题解:暴力筛合数,然后暴力找 // ...
- Oracle的分区操作和修改分区主键
1.增加一个分区ALTER TABLE sales ADD PARTITION jan96 VALUES LESS THAN ( '01-FEB-1999' ) TABLESPACE tsx;增加一个 ...
- isNaN() 确认是否是数字
isNaN(x): 当变量 x 不是数字,返回 true: 当变量 x 是其他值,(比如,1,2,3),返回false.
- 输入三个数a,b,c,要示按由小到大的顺序输出
#include<stdio.h>int main(){ double a,b,c,t; scanf("%lf %lf %lf",&a, ...
- UI第五节——手势
#import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL ...
- Reflect(欧拉函数)
Reflect Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- 资源URL地址记录
1. 如何搭建VPN服务器 http://www.360doc.com/content/11/0217/11/3084932_93749130.shtml http://www.softxp.net/ ...
- 原生态js获取节点的方法
<input value="我是用id来获取值的" type="button" onclick="GetById()"/> &l ...
- Go - 内置函数大全
Package builtin import "builtin" Overview Index Overview ▾ Package builtin provides docume ...
- MySQL也有潜规则 – Select 语句不加 Order By 如何排序?
今天遇到一个问题,有一个 Select 语句没有加 "Order By",返回的数据是不确定的. 这种问题碰到不止几次了.追根寻底, Select 语句如果不加 "Ord ...