【POJ 1981 】Circle and Points
当两个点距离小于直径时,由它们为弦确定的一个单位圆(虽然有两个圆,但是想一想知道只算一个就可以)来计算覆盖多少点。
- #include <cstdio>
- #include <cmath>
- #define N 301
- #define eps 1e-5
- using namespace std;
- int n,ans,tol;
- double x[N],y[N],dx,dy;
- inline double sqr(double x)
- {
- return x*x;
- }
- inline double dis(int a,int b)
- {
- return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
- }
- inline void solve()
- {
- tol=;
- for(int i=; i<=n; i++)
- if(dis(,i)<=+eps)
- tol++;
- if(tol>ans)ans=tol;
- }
- inline void get(int a,int b){
- double v=atan((x[b]-x[a])/(y[a]-y[b]));//等于0时会返回inf,v=pi/2
- double c=sqrt(-sqr(dis(a,b)/2.0));
- dx= c*cos(v);
- dy= c*sin(v);
- }
- int main()
- {
- while(scanf("%d",&n)&&n)
- {
- ans=;
- for (int i=; i<=n; i++)
- scanf("%lf%lf",&x[i],&y[i]);
- for (int i=; i<=n; i++)
- for (int j=i+; j<=n; j++)
- if(dis(i,j)<){
- double mx=(x[i]+x[j])/2.0,my=(y[i]+y[j])/2.0;
- get(i,j);
- x[]=mx+dx,y[]=my+dy;
- solve();
- }
- printf("%d\n",ans);
- }
- }
【POJ 1981 】Circle and Points的更多相关文章
- 【POJ 1981】Circle and Points(已知圆上两点求圆心坐标)
[题目链接]:http://poj.org/problem?id=1981 [题意] 给你n个点(n<=300); 然后给你一个半径R: 让你在平面上找一个半径为R的圆; 这里R=1 使得这个圆 ...
- 【poj 3090】Visible Lattice Points(数论--欧拉函数 找规律求前缀和)
题意:问从(0,0)到(x,y)(0≤x, y≤N)的线段没有与其他整数点相交的点数. 解法:只有 gcd(x,y)=1 时才满足条件,问 N 以前所有的合法点的和,就发现和上一题-- [poj 24 ...
- 【POJ 3090】 Visible Lattice Points
[题目链接] http://poj.org/problem?id=3090 [算法] 通过观察发现,在这个平面直角坐标系中,除了(1,1),(1,0)和(0,1),所有可见点的横纵坐标互质 那么,问题 ...
- POJ - 1981 :Circle and Points (圆的扫描线) hihocoder1508
题意:给定N个点,然后给定一个半径为R的圆,问这个圆最多覆盖多少个点. 思路:在圆弧上求扫描线. 如果N比较小,不难想到N^3的算法. 一般这种覆盖问题你可以假设有两个点在圆的边界上,那么每次产生的圆 ...
- 【POJ 1201】 Intervals(差分约束系统)
[POJ 1201] Intervals(差分约束系统) 11 1716的升级版 把原本固定的边权改为不固定. Intervals Time Limit: 2000MS Memory Limit: ...
- 【POJ 2750】 Potted Flower(线段树套dp)
[POJ 2750] Potted Flower(线段树套dp) Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4566 ...
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
- 【链表】BZOJ 2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 382 Solved: 111[Submit][S ...
- BZOJ2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 284 Solved: 82[Submit][St ...
随机推荐
- NOIP2015 运输计划(bzoj4326)
4326: NOIP2015 运输计划 Time Limit: 30 Sec Memory Limit: 128 MBSubmit: 886 Solved: 574[Submit][Status] ...
- NSDate 哪些事
.什么是时间戳? 时间戳是自 1970 年 1 月 1 日(00:00:00 GMT)至当前时间的总秒数. 2.NSDate,时间戳,NSString 之间的转换 //string 转 date + ...
- MVC 数据验证【转】
[转自]http://www.cnblogs.com/dozer/archive/2010/04/12/MVC-DataAnnotations.html 作者Dozer 今天在这里给大家介绍一下MVC ...
- NLog 通过http保存日志
from:https://github.com/NLog/NLog/wiki/WebService-target Example config: <nlog throwExceptions='t ...
- memcached的图形界面监控
前提是已经安装了php和memcached 图形界面的监控是通过memcache.php来实现的, 1.把该php程序拷贝到apache的web根目录 [root@cacti srv]# ...
- ubuntu12.04禁止单用户本地无密码root登录
1)grub-mkpasswd-pbkdf2 拿到类似grub.pbkdf2.sha512.10000.C093FE6825CDCC2F84934ABC406445E92EE098733C60E6D1 ...
- OmniPlan文档链接
https://support.omnigroup.com/documentation/omniplan/mac/3.0/zh/introduction/#introduction
- 【转】【MySQL】mysql 通过bin-log恢复数据方法详解
mysql中bin-log在mysql默认状态下是没有打开的,我们要先打开mysql 开启bin-log功能,然后再通过备份的bin-log进行数据库恢复了. 具体的操作是通过mysqlbinlog这 ...
- 阿里云Center OS 6.2 Nginx 配置 SSL/TLS HTTPS配置
1.通过https://www.startssl.com/ 免费SSL证书 STARTSSL 跟VeriSign一样,StartSSL(网址:http://www.startssl.com,公司名:S ...
- CoffeeScript的类继承的工具函数extends
__hasProp = {}.hasOwnProperty, __extends = function(child, parent) { // 派生类时,如果基类的类属性值是对象,那么子类的类属性只是 ...