POJ 1106 Transmitters
来源:互联网 发布:2016淘宝达人怎么赚钱 编辑:程序博客网 时间:2024/04/28 13:07
给定一些点,和一个圆心坐标,求一个以这个点为圆心的半圆能最多能圈下多少点。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;#define hPI 1.5707963267949#define eps 1e-8struct point{ double x; double y;};double cross(point a,point b,point c){ a.x-=c.x;a.y-=c.y; b.x-=c.x;b.y-=c.y; return a.x*b.y-a.y*b.x;}double mul(point a,point b,point c){ a.x-=c.x;a.y-=c.y; b.x-=c.x;b.y-=c.y; return a.x*b.x+a.y*b.y;}double dist(point a,point b){ return sqrt(mul(a,a,b));}double angle(point a,point b,point c){ return cross(a,b,c)/dist(a,c)/dist(b,c);}int main(){ double r,t; point p[200],o; int lp,i,j,ans,t1,t2; while (scanf("%lf%lf%lf",&o.x,&o.y,&r) != EOF) { if (r < 0) break; ans=0; scanf("%d",&lp); for (i=0; i<lp; i++) { scanf("%lf%lf",&p[i].x,&p[i].y); } for (i=0; i<lp; i++) { t1=1; t2=1; t=dist(p[i],o); if (t > r) continue; for (j=0; j<lp; j++) { if (i == j) continue; t=dist(p[j],o); // printf("%d %d %lf ",i,j,t); if (t > r) continue; t=angle(p[i],p[j],o); //printf(" %lf\n",t); if (t > 0) t1++; else if (t < 0) t2++; else if (fabs(t-0.0) < eps) { t1++; t2++; } } // printf("\nt1=%d t2=%d\n",t1,t2); t1=t1>t2?t1:t2; ans=ans>t1?ans:t1; } printf("%d\n",ans); }}
- POJ 1106 Transmitters
- poj 1106 Transmitters
- POJ 1106 Transmitters
- POJ 1106 Transmitters
- POJ 1106 Transmitters
- POJ 1106 Transmitters
- POJ 1106 Transmitters
- POJ 1106 Transmitters
- POJ 1106 Transmitters
- zoj 1041 || poj 1106 Transmitters
- POJ-1106 Transmitters解题报告
- POJ 1106 Transmitters 计算几何
- POJ 1106 Transmitters(叉积)
- poj 1106 Transmitters 计算几何
- POJ 1106 Transmitters(离散化)
- poj 1106 Transmitters(极角排序)
- POJ 1106 Transmitters (简单计算几何)
- POJ 1106 Transmitters (几何覆盖问题)
- [sipdroid]sipdroid目录结构和其他说明
- 传智播客开设Unity3d游戏开发及.Net开发Android程序课程
- Android getevent及sendevent分析
- 关于js中函数的动态调用
- 酒桌上的规矩,社会潜规则
- POJ 1106 Transmitters
- struts地址栏中重写Url
- asp.net 应用程序对象 HttpContext 和 HttpApplication (1)
- 软件项目管理系统-采购商品管理-采购订单一览
- iPhone手机和Android手机的对比
- 虚函数和纯虚函数
- 文件大小和占用空间的区别
- eclipse.ini/myeclipse.ini中配置参数 -Xms,-Xmx,-PerSize //优化eclipse
- 用WPF做一个像QQ登陆界面一样的窗体