CodeForces_507B_Amr and Pins(思维题)
来源:互联网 发布:mac文件重命名快捷键 编辑:程序博客网 时间:2024/04/29 13:41
题型:计算几何
题意:
圆心为(x,y),半径为r的圆,现在有如下操作,在圆上设置一个点,让圆围绕改点旋转任意角度,然后取消这个点。
问最少需要几次这样的操作,是的圆心能够移动到(xx,yy)上。
分析:
若(xx,yy)与(x,y)的距离dist在直径以内,那么总能找到一个点,使得一次操作就能成功,所以,答案就是dist/(2*r)向上取整。
需要注意精度问题,被坑了几发。
代码:
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#define eps 1e-15using namespace std;int r,x,y,_x,_y;int main() { while(~scanf("%d%d%d%d%d",&r,&x,&y,&_x,&_y)) { if(x==_x && y==_y) { puts("0"); continue; } double xx = x+0.0; double yy = y+0.0; double _xx = _x+0.0; double _yy = _y+0.0;// printf("%lf %lf \n",xx-yy,_xx-_yy); double dist = sqrt((xx-_xx)*(xx-_xx)+(yy-_yy)*(yy-_yy));// printf("%lf\n",dist); double ts = dist / (2*r); int ttss = (int)ts; if(ts-ttss+0.0>eps) ttss+=1; printf("%d\n",ttss); } return 0;}/**2 0 0 0 41 1 1 4 44 5 6 5 64 0 0 1 04 0 0 4 04 0 0 8 08066 7339 19155 -90534 -60666*/
0 0
- CodeForces_507B_Amr and Pins(思维题)
- Codeforces 507B Amr and Pins【思维】
- Amr and Pins
- B. Amr and Pins
- B. Amr and Pins
- Amr and Pins
- B. Amr and Pins
- codeforces-#287-- 507B Amr and Pins
- coderforce 2057B Amr and Pins
- Codeforces-507B-Amr and Pins
- B. Amr and Pins( Codeforces Round #287 (Div. 2))
- B. Amr and Pins (Codeforces Round #287 (div2))
- Amr and Pins——圆的旋转
- codeforces--507A--A. Amr and Music--507B--B. Amr and Pins
- A. Dima and Guards 【思维 好题】
- qdu Mathematics and Geometry(思维题)
- A. Alyona and copybooks--思维水题
- C. Alyona and mex--思维水题
- redmine tab显示相关
- awk 实例练习(二)
- 佩兰发现了谁
- @property中retain assign copy详解
- java访问 HDFS文件资源
- CodeForces_507B_Amr and Pins(思维题)
- PHP获取指定月份的第一天开始和最后一天结束的时间戳函数
- android greendaoMaster的应用
- Vs2008 linq To sql classes 无法生成类的集合解决方法
- 闪靓族
- 水族商道资讯
- Redis数据持久化方式
- JAVA 超时
- 【BZOJ】【P1833】【ZJOI2010】【count 数字计数】【题解】【数位DP】