hiho一下 第111周 AFarthest Point(计算几何)
来源:互联网 发布:项目中多线程编程案例 编辑:程序博客网 时间:2024/06/06 00:58
传送门
描述
Given a circle on a two-dimentional plane.
Output the integral point in or on the boundary of the circle which has the largest distance from the center.
输入
One line with three floats which are all accurate to three decimal places, indicating the coordinates of the center x, y and the radius r.
For 80% of the data: |x|,|y|<=1000, 1<=r<=1000
For 100% of the data: |x|,|y|<=100000, 1<=r<=100000
输出
One line with two integers separated by one space, indicating the answer.
If there are multiple answers, print the one with the largest x-coordinate.
If there are still multiple answers, print the one with the largest y-coordinate.
样例输入
1.000 1.000 5.000
样例输出
6 1
题目大意:
给定平面直角坐标系中的一个圆,求圆内(可以在边界上)离圆心最远的整点,但是如果有多组答
案的话,应该输出
解题思路:
(采用hiho的答案)传送门
需要注意的是这个图 有点不太准确,他的那个 x 坐标和 y 坐标放错位置了。。。在纸上一画就知道
了
/**2016 - 08 - 20 上午Author: ITAKMotto:今日的我要超越昨日的我,明日的我要胜过今日的我,以创作出更好的代码为目标,不断地超越自己。**/#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <algorithm>#include <set>using namespace std;typedef long long LL;typedef unsigned long long ULL;const int INF = 1e9+5;const int MAXN = 1e6+5;const int MOD = 1e9+7;const double eps = 1e-9;const double PI = acos(-1);using namespace std;LL Scan_LL()///输入外挂{ LL res=0,ch,flag=0; if((ch=getchar())=='-') flag=1; else if(ch>='0'&&ch<='9') res=ch-'0'; while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0'; return flag?-res:res;}int Scan_Int()///输入外挂{ int res=0,ch,flag=0; if((ch=getchar())=='-') flag=1; else if(ch>='0'&&ch<='9') res=ch-'0'; while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0'; return flag?-res:res;}void Out(LL a)///输出外挂{ if(a>9) Out(a/10); putchar(a%10+'0');}double Dis(double ax, double ay, double bx, double by){ return (ax-bx)*(ax-bx)+(ay-by)*(ay-by);}int main(){ double xc, yc, r; while(~scanf("%lf%lf%lf",&xc,&yc,&r)) { int ret_x, ret_y; double Max = -12345; for(int x=floor(xc+r); x>=ceil(xc-r); x--) { double d = sqrt( (r*r) - (x-xc)*(x-xc) ); int ty1 = floor(yc+d), ty2 = ceil(yc-d); if(Dis(x, ty1, xc, yc) > Max + eps) { Max = Dis(x, ty1, xc, yc); ret_x = x; ret_y = ty1; } if(Dis(x, ty2, xc, yc) > Max + eps) { Max = Dis(x, ty2, xc, yc); ret_x = x; ret_y = ty2; } } printf("%d %d\n",ret_x, ret_y); } return 0;}
- hiho一下 第111周 AFarthest Point(计算几何)
- hiho一下 第143周 hiho密码
- hiho一下 第141周
- hiho一下 第139周
- hiho一下第143周
- hiho一下 第145周
- hiho一下 第167周
- hiho一下 第175周
- hiho一下 第174周
- hiho一下 第135周 九宫 (枚举幻方)
- hihoCoder hiho一下 第148周--Font Size (模拟)
- hiho一下 第156周 岛屿 (dfs)
- hiho一下 第157周 二进制小数 (二进制)
- hiho一下 第158周 非法二进制数 (dp)
- hiho一下第56周 高斯消元
- hiho一下 第113周 Fibonacci (dp)
- [hiho一下 第128周] 后缀自动机
- [hiho一下 第129周] 后缀自动机
- 使用MediaRecorder进行录音
- Android四大基本组件介绍与生命周期
- hadoop性能调优之参数调优
- viewpager设置预加载页面数目
- php之获取指定年月的月初月末时间戳
- hiho一下 第111周 AFarthest Point(计算几何)
- RDF,OWL相关文档材料汇总以及下载链接
- Java初始化顺序
- stm32f407 discovery ISP
- UVa 1401 字典树+DP
- windows 指令创建磁盘映射 net use
- 100天土鸡饲养计划(30)
- hdu 4460 Friend Chains(bfs)
- MediaRecorder录音,解决stop,start错误