当两个点距离小于直径时,由它们为弦确定的一个单位圆(虽然有两个圆,但是想一想知道只算一个就可以)来计算覆盖多少点。

  1. #include <cstdio>
  2. #include <cmath>
  3. #define N 301
  4. #define eps 1e-5
  5. using namespace std;
  6. int n,ans,tol;
  7. double x[N],y[N],dx,dy;
  8. inline double sqr(double x)
  9. {
  10. return x*x;
  11. }
  12. inline double dis(int a,int b)
  13. {
  14. return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
  15. }
  16. inline void solve()
  17. {
  18. tol=;
  19. for(int i=; i<=n; i++)
  20. if(dis(,i)<=+eps)
  21. tol++;
  22. if(tol>ans)ans=tol;
  23. }
  24. inline void get(int a,int b){
  25. double v=atan((x[b]-x[a])/(y[a]-y[b]));//等于0时会返回inf,v=pi/2
  26. double c=sqrt(-sqr(dis(a,b)/2.0));
  27. dx= c*cos(v);
  28. dy= c*sin(v);
  29. }
  30. int main()
  31. {
  32. while(scanf("%d",&n)&&n)
  33. {
  34. ans=;
  35. for (int i=; i<=n; i++)
  36. scanf("%lf%lf",&x[i],&y[i]);
  37. for (int i=; i<=n; i++)
  38. for (int j=i+; j<=n; j++)
  39. if(dis(i,j)<){
  40. double mx=(x[i]+x[j])/2.0,my=(y[i]+y[j])/2.0;
  41. get(i,j);
  42. x[]=mx+dx,y[]=my+dy;
  43. solve();
  44. }
  45. printf("%d\n",ans);
  46. }
  47. }
  48.   

【POJ 1981 】Circle and Points的更多相关文章

  1. 【POJ 1981】Circle and Points(已知圆上两点求圆心坐标)

    [题目链接]:http://poj.org/problem?id=1981 [题意] 给你n个点(n<=300); 然后给你一个半径R: 让你在平面上找一个半径为R的圆; 这里R=1 使得这个圆 ...

  2. 【poj 3090】Visible Lattice Points(数论--欧拉函数 找规律求前缀和)

    题意:问从(0,0)到(x,y)(0≤x, y≤N)的线段没有与其他整数点相交的点数. 解法:只有 gcd(x,y)=1 时才满足条件,问 N 以前所有的合法点的和,就发现和上一题-- [poj 24 ...

  3. 【POJ 3090】 Visible Lattice Points

    [题目链接] http://poj.org/problem?id=3090 [算法] 通过观察发现,在这个平面直角坐标系中,除了(1,1),(1,0)和(0,1),所有可见点的横纵坐标互质 那么,问题 ...

  4. POJ - 1981 :Circle and Points (圆的扫描线) hihocoder1508

    题意:给定N个点,然后给定一个半径为R的圆,问这个圆最多覆盖多少个点. 思路:在圆弧上求扫描线. 如果N比较小,不难想到N^3的算法. 一般这种覆盖问题你可以假设有两个点在圆的边界上,那么每次产生的圆 ...

  5. 【POJ 1201】 Intervals(差分约束系统)

    [POJ 1201] Intervals(差分约束系统) 11 1716的升级版 把原本固定的边权改为不固定. Intervals Time Limit: 2000MS   Memory Limit: ...

  6. 【POJ 2750】 Potted Flower(线段树套dp)

    [POJ 2750] Potted Flower(线段树套dp) Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4566   ...

  7. bzoj 2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...

  8. 【链表】BZOJ 2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 382  Solved: 111[Submit][S ...

  9. BZOJ2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 284  Solved: 82[Submit][St ...

随机推荐

  1. NOIP2015 运输计划(bzoj4326)

    4326: NOIP2015 运输计划 Time Limit: 30 Sec  Memory Limit: 128 MBSubmit: 886  Solved: 574[Submit][Status] ...

  2. NSDate 哪些事

    .什么是时间戳? 时间戳是自 1970 年 1 月 1 日(00:00:00 GMT)至当前时间的总秒数. 2.NSDate,时间戳,NSString 之间的转换 //string 转 date + ...

  3. MVC 数据验证【转】

    [转自]http://www.cnblogs.com/dozer/archive/2010/04/12/MVC-DataAnnotations.html 作者Dozer 今天在这里给大家介绍一下MVC ...

  4. NLog 通过http保存日志

    from:https://github.com/NLog/NLog/wiki/WebService-target Example config: <nlog throwExceptions='t ...

  5. memcached的图形界面监控

    前提是已经安装了php和memcached   图形界面的监控是通过memcache.php来实现的,   1.把该php程序拷贝到apache的web根目录   [root@cacti srv]# ...

  6. ubuntu12.04禁止单用户本地无密码root登录

    1)grub-mkpasswd-pbkdf2 拿到类似grub.pbkdf2.sha512.10000.C093FE6825CDCC2F84934ABC406445E92EE098733C60E6D1 ...

  7. OmniPlan文档链接

    https://support.omnigroup.com/documentation/omniplan/mac/3.0/zh/introduction/#introduction

  8. 【转】【MySQL】mysql 通过bin-log恢复数据方法详解

    mysql中bin-log在mysql默认状态下是没有打开的,我们要先打开mysql 开启bin-log功能,然后再通过备份的bin-log进行数据库恢复了. 具体的操作是通过mysqlbinlog这 ...

  9. 阿里云Center OS 6.2 Nginx 配置 SSL/TLS HTTPS配置

    1.通过https://www.startssl.com/ 免费SSL证书 STARTSSL 跟VeriSign一样,StartSSL(网址:http://www.startssl.com,公司名:S ...

  10. CoffeeScript的类继承的工具函数extends

    __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { // 派生类时,如果基类的类属性值是对象,那么子类的类属性只是 ...